[yast-commit] r40444 - in /trunk/ftp-server/src: FtpServer.ycp dialogs.ycp wid_functions.ycp write_load.ycp
Author: juhliarik Date: Fri Aug 24 13:07:51 2007 New Revision: 40444 URL: http://svn.opensuse.org/viewcvs/yast?rev=40444&view=rev Log: added patch for changes permission for upload dir (anonymous users) Modified: trunk/ftp-server/src/FtpServer.ycp trunk/ftp-server/src/dialogs.ycp trunk/ftp-server/src/wid_functions.ycp trunk/ftp-server/src/write_load.ycp Modified: trunk/ftp-server/src/FtpServer.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ftp-server/src/FtpServer.ycp?rev=40444&r1=40443&r2=40444&view=diff ============================================================================== --- trunk/ftp-server/src/FtpServer.ycp (original) +++ trunk/ftp-server/src/FtpServer.ycp Fri Aug 24 13:07:51 2007 @@ -146,6 +146,27 @@ global boolean upload_good_permission = false; /** + * variable signifies if upload dir for anonymous has good permissions + * it is only for pure-ftpd + * + * -1 == home dir is "/" + * 0 == writting access disallow + * 1 == writting allowed + * global integer variable + */ + +global integer pure_ftp_allowed_permissios_upload = 0; + +/** + * variable signifies if user choose change permissions for home dir + * for anonymous connections with allowed upload + * + * global boolean variable + */ + +global boolean change_permissions = false; + +/** * variable signifies home dir for anonymous user * * global string variable @@ -339,11 +360,72 @@ } } } + return result; } +/** + * Read pure-fptd configuration + * checking permissions for upload + * + * @return boolean successfull + */ + + +boolean ReadPermisionUplaod () { + + boolean result = false; + string command = ""; + string directory = ""; + string upload_dir = ""; + + list <string> directories = filter(string key, splitstring(anon_homedir, "/"), {return (key != "");}); + + y2milestone("[ftp-server] (ReadPermisionUplaod) rozzekane directories...: %1 ",directories); + + if (size(directories) == 1 ) { + directory = "/"; + upload_dir = deletechars(anon_homedir,"/"); + + } else if (size(directories) > 1 ) { + upload_dir = directories[(size(directories)-1)]:""; + //Popup::Message(upload_dir); + directory = "/" + mergestring(remove(directories, (size(directories)-1)), "/"); + //Popup::Message(directory); + } else { + pure_ftp_allowed_permissios_upload = -1; + + } + + + if ((anon_homedir !="") && (pure_ftp_allowed_permissios_upload != -1)) + command = "ls -l "+directory+ " | grep "+ upload_dir; + if (command != "") { + map options = (map)SCR::Execute (.target.bash_output, command); + y2milestone("[ftp-server] (ReadPermisionUplaod) command for checking permissions for upload dir: %1",command); + if (options["exit"]:nil == 0) + result = true; + else + result = false; + if (result) { + string permissions = substring (tostring(options["stdout"]:nil),0,10); + string w = filterchars (permissions, "w"); + string r = filterchars (permissions, "r"); + if ((size(w) <3) || (size(r) <3)) { + pure_ftp_allowed_permissios_upload = 0; + //Popup::Message("good permissions"); + } else { + pure_ftp_allowed_permissios_upload = 1; + //Popup::Message("wrong permissions"); + } + } + //Popup::Message(tostring(pure_ftp_allowed_permissios_upload)); + } + return result; + +} /** * Remap current pure -FtpServer configuration @@ -351,6 +433,7 @@ * * @return boolean successfull */ + boolean InitEDIT_SETTINGS () { foreach (string key, UI_keys, { string val = ValueUI(key, false); @@ -414,9 +497,10 @@ SuSEFirewall::Read (); Progress::set (progress_orig); //read existing upload directory for vsftpd - if (vsftpd_edit) { + if (vsftpd_edit) result = ReadVSFTPDUpload (); - } + + result = ReadPermisionUplaod (); return result; } @@ -646,7 +730,7 @@ command = command + EDIT_SETTINGS["FTPUser"]:nil +":"+EDIT_SETTINGS["FTPUser"]:nil; command = command + " " + anon_homedir + upload + "; chmod 766 "; - command = command + anon_homedir +upload + "; else chmod 766 " + anon_homedir +"upload; fi"; + command = command + anon_homedir +upload + "; else chmod 766 " + anon_homedir +upload+"; fi"; /* "dir=`ls /srv/ftp/ | grep upload`; if [ -z $dir ]; then echo $dir; mkdir /srv/ftp/upload; chown ftp:ftp /srv/ftp/upload/; chmod 755 /srv/ftp/upload; else chmod 766 /srv/ftp/upload/; fi" @@ -672,6 +756,18 @@ if (Service::Status("pure-ftpd") == 0) options = (map)SCR::Execute (.target.bash_output, "rcpure-ftpd restart"); } + + //update permissions for home directory if upload is enabled... + if ((pure_ftp_allowed_permissios_upload != -1) && (change_permissions)) { + if (vsftpd_edit) { + command = "chmod 755 " + anon_homedir; + options = (map)SCR::Execute (.target.bash_output, command); + } else { + command = "chmod 777 " + anon_homedir; + options = (map)SCR::Execute (.target.bash_output, command); + } + } + return result; } /** Modified: trunk/ftp-server/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ftp-server/src/dialogs.ycp?rev=40444&r1=40443&r2=40444&view=diff ============================================================================== --- trunk/ftp-server/src/dialogs.ycp (original) +++ trunk/ftp-server/src/dialogs.ycp Fri Aug 24 13:07:51 2007 @@ -683,6 +683,7 @@ result["widget"] = `checkbox; result["init"] = InitAnonReadOnly; result["store"] = StoreAnonReadOnly; + result["handle"] = HandleAnonReadOnly; result["help"] = DialogHelpText("AnonReadOnly"); return result; @@ -704,6 +705,7 @@ result["widget"] = `checkbox; result["init"] = InitAnonCreatDirs; result["store"] = StoreAnonCreatDirs; + result["handle"] = HandleAnonCreatDirs; result["help"] = DialogHelpText("AnonCreatDirs"); return result; Modified: trunk/ftp-server/src/wid_functions.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ftp-server/src/wid_functions.ycp?rev=40444&r1=40443&r2=40444&view=diff ============================================================================== --- trunk/ftp-server/src/wid_functions.ycp (original) +++ trunk/ftp-server/src/wid_functions.ycp Fri Aug 24 13:07:51 2007 @@ -1178,6 +1178,60 @@ } /** + * Handle function of "Anonymous Can Upload" + * check permissions for upload dir + * + */ + +symbol HandleAnonReadOnly (string key, map event) { + string yesno_comment =""; + string yesno_question =""; + boolean result = false; + boolean enable = (boolean) UI::QueryWidget(`id("AnonReadOnly"), `Value); + + + if (enable) { + + if (!FtpServer::vsftpd_edit) { + + if (FtpServer::pure_ftp_allowed_permissios_upload == 0) { + yesno_question = sformat(_("Change permission of %1 ?\n"), FtpServer::anon_homedir); + yesno_comment = sformat(_("If you want to allow uploads for \"anonymous\" users, \nyou need a directory with write access for them.")); + result = Popup::YesNoHeadline(yesno_question, yesno_comment); + if (result) { + FtpServer::pure_ftp_allowed_permissios_upload = 1; + FtpServer::change_permissions = true; + } else { + FtpServer::pure_ftp_allowed_permissios_upload = -1; + FtpServer::change_permissions = false; + } + } //end of if (FtpServer::pure_ftp_allowed_permissios_upload == 0) + + } else { + + if (FtpServer::pure_ftp_allowed_permissios_upload == 1) { + yesno_question = sformat(_("Change permission of %1 ?\n"), FtpServer::anon_homedir); + yesno_comment = sformat(_("For anonymous connections, it is necessary\n that a home directory of an anonymous user is not writeable.")); + result = Popup::YesNoHeadline(yesno_question, yesno_comment); + if (result) { + FtpServer::pure_ftp_allowed_permissios_upload = 0; + FtpServer::change_permissions = true; + } else { + FtpServer::pure_ftp_allowed_permissios_upload = -1; + FtpServer::change_permissions = false; + } + } //end of if (FtpServer::pure_ftp_allowed_permissios_upload == 1) + + + } //end else for if if (!FtpServer::vsftpd_edit) { + + + } // end of if (enable) { + + +} + +/** * Store function of "Anonymous Can Upload" * save value to temporary structure * @@ -1202,6 +1256,63 @@ /** + * Handle function of "Anonymous Can Create Directories" + * check permissions for upload dir + * + */ + +symbol HandleAnonCreatDirs (string key, map event) { + string yesno_comment =""; + string yesno_question =""; + boolean result = false; + boolean enable = (boolean) UI::QueryWidget(`id("AnonReadOnly"), `Value); + + + if (enable) { + + if (!FtpServer::vsftpd_edit) { + + if (FtpServer::pure_ftp_allowed_permissios_upload == 0) { + yesno_question = sformat(_("Change permission of %1 ?\n"), FtpServer::anon_homedir); + yesno_comment = sformat(_("If you want to allow uploads for \"anonymous\" users, \nyou need a directory with write access for them.")); + result = Popup::YesNoHeadline(yesno_question, yesno_comment); + if (result) { + FtpServer::pure_ftp_allowed_permissios_upload = 1; + FtpServer::change_permissions = true; + } else { + FtpServer::pure_ftp_allowed_permissios_upload = -1; + FtpServer::change_permissions = false; + } + } //end of if (FtpServer::pure_ftp_allowed_permissios_upload == 0) + + } else { + + if (FtpServer::pure_ftp_allowed_permissios_upload == 1) { + yesno_question = sformat(_("Change permission of %1 ?\n"), FtpServer::anon_homedir); + yesno_comment = sformat(_("For anonymous connections, it is necessary\n that a home directory of an anonymous user is not writeable.")); + result = Popup::YesNoHeadline(yesno_question, yesno_comment); + if (result) { + FtpServer::pure_ftp_allowed_permissios_upload = 0; + FtpServer::change_permissions = true; + } else { + FtpServer::pure_ftp_allowed_permissios_upload = -1; + FtpServer::change_permissions = false; + } + } //end of if (FtpServer::pure_ftp_allowed_permissios_upload == 1) + + + } //end else for if if (!FtpServer::vsftpd_edit) { + + + } // end of if (enable) { + + +} + + + + +/** * Store function of "Anonymous Can Create Directories" * save value to temporary structure * Modified: trunk/ftp-server/src/write_load.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ftp-server/src/write_load.ycp?rev=40444&r1=40443&r2=40444&view=diff ============================================================================== --- trunk/ftp-server/src/write_load.ycp (original) +++ trunk/ftp-server/src/write_load.ycp Fri Aug 24 13:07:51 2007 @@ -902,7 +902,7 @@ FtpServer::VS_SETTINGS["dsa_cert_file"] = nil; } else { return ((haskey(FtpServer::VS_SETTINGS, "dsa_cert_file") ? - toupper(FtpServer::VS_SETTINGS["dsa_cert_file"]:nil) : FtpServer::DEFAULT_CONFIG["CertFile"]:nil)); + FtpServer::VS_SETTINGS["dsa_cert_file"]:nil : FtpServer::DEFAULT_CONFIG["CertFile"]:nil)); } } else { if (!write) -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
juhliarik@svn.opensuse.org