diff --git a/build/scripts/setup/script.d/03-setup-casaos.sh b/build/scripts/setup/script.d/03-setup-casaos.sh old mode 100755 new mode 100644 diff --git a/build/sysroot/usr/share/casaos/shell/helper.sh b/build/sysroot/usr/share/casaos/shell/helper.sh index c6f576d..9ec473c 100644 --- a/build/sysroot/usr/share/casaos/shell/helper.sh +++ b/build/sysroot/usr/share/casaos/shell/helper.sh @@ -336,9 +336,16 @@ RestartSMBD(){ $sudo_cmd systemctl restart smbd } -# edit user password $1:username +# edit user password EditSmabaUserPassword(){ - $sudo_cmd smbpasswd $1 + $sudo_cmd smbpasswd -a $1 < 0 { + users := `valid users =` + for _, user := range share.Valid_users { + users = " " + user + } + return users + "\n" + } + return "" +} + func (s *sharesStruct) UpdateConfigFile() { shares := []model2.SharesDBModel{} - s.db.Select("anonymous,path").Find(&shares) + s.db.Select("anonymous,path,valid_users").Find(&shares) // generated config file configStr := "" for _, share := range shares { @@ -79,16 +104,15 @@ func (s *sharesStruct) UpdateConfigFile() { configStr += ` [` + dirName + `] comment = CasaOS share ` + dirName + ` -public = Yes +public = ` + getAnonymous(share) + ` path = ` + share.Path + ` browseable = Yes read only = No -guest ok = Yes +guest ok = ` + getAnonymous(share) + ` create mask = 0777 directory mask = 0777 -force user = root - -` +` + forceRoot(share) + ` +` + getValidUsers(share) } // write config file file.WriteToPath([]byte(configStr), "/etc/samba", "smb.casa.conf")