ACC SHELL
/**
* File: modules/PamSettings.ycp
* Package: yast2-pam
* Summary: YaST intrerface for /etc/default/passwd agent
* Authors: Jiri Suchomel <jsuchome@suse.cz>
* Flags: Unstable
*
* $Id: PamSettings.ycp 57400 2009-06-02 20:39:28Z jsuchome $
*
*/
{
module "PamSettings";
import "Pam";
/**
* Was /etc/default/passwd modified?
*/
boolean default_passwd_modified = false;
list<string> security_files = [];
//---------------------------- functions for handling /etc/default/passwd
/**
* Reads the value of default crypt hash (defined in /etc/default/passwd)
*/
global define string GetHashMethod () {
string m = (string) SCR::Read (.etc.default.passwd.crypt);
if (m == nil || m == "")
m = "md5";
return m;
}
/**
* Reads the value of default crypt hash for group passwords
*/
global define string GetGroupHashMethod () {
any g = SCR::Read (.etc.default.passwd.group_crypt);
if (g != nil && is (g, string) && (string) g != "")
return (string) g;
else return GetHashMethod ();
}
/**
* Reads the value from /etc/default/passwd
*/
global define string GetDefaultValue (string key) {
return (string) SCR::Read (add (.etc.default.passwd, key));
}
/**
* Sets the new value of default crypt hash - modifies /etc/default/passwd !
* @param hash the new value of hash
* @example
* SetValues ("md5")
*/
global define boolean SetHashMethod (string hash) {
if (GetHashMethod () != hash)
{
default_passwd_modified = true;
}
default_passwd_modified = true;
return SCR::Write (.etc.default.passwd.crypt, hash);
}
/**
* Sets the new value of default crypt hash for group passwords
* @param hash the new value of hash
*/
global define boolean SetGroupHashMethod (string hash) {
if (GetGroupHashMethod () != hash)
{
default_passwd_modified = true;
}
return SCR::Write (.etc.default.passwd.group_crypt, hash);
}
/**
* Set the value of key in /etc/default/passwd
*/
global define boolean SetDefaultValue (string key, string value) {
if (GetDefaultValue (key) != value)
{
default_passwd_modified = true;
}
return SCR::Write (add (.etc.default.passwd, key), value);
}
//---------------------------- common functions ------------------------------
/**
* Writes all edited files to the disk
* @param force - write everythink, even if modification was not detected
* @return true on success
*/
global define boolean Write (boolean force) {
boolean ret = true;
if (default_passwd_modified || force)
ret = ret && SCR::Write (.etc.default.passwd, nil);
return ret;
}
}//EOF
ACC SHELL 2018