ACC SHELL
/**
* File: modules/UsersUI.ycp
* Package: Configuration of users and groups
* Summary: UI-related routines to be run from perl modules (Users.pm etc.)
* Author: Jiri Suchomel <jsuchome@suse.cz>
*
* $Id: UsersUI.ycp 58405 2009-08-20 14:44:10Z jsuchome $
*/
{
module "UsersUI";
textdomain "users";
import "Label";
/**
* Return the translated name for system user
*/
global define string SystemUserName (string name) ``{
// TODO users are added manualy.... :-(
map SystemUsers = $[
/* User name for user: "root" */
"root" : _("root"),
/* User name for user: "bin" */
"bin" : _("bin"),
/* User name for user: "daemon" */
"Daemon" : _("Daemon"),
/* User name for user: "lp" */
"Printing daemon" : _("Printing Daemon"),
/* User name for user: "mail" */
"Mailer daemon" : _("Mailer Daemon"),
/* User name for user: "news" */
"News system" : _("News System"),
/* User name for user: "uucp" */
"Unix-to-Unix CoPy system" : _("Unix-to-Unix Copy System"),
/* User name for user: "games" */
"Games account" : _("Games Account"),
/* User name for user: "man" */
"Manual pages viewer" : _("Manual Page Viewer"),
/* User name for user: "at" */
"Batch jobs daemon" : _("Batch Jobs Daemon"),
/* User name for user: "wwwrun" */
"WWW daemon apache" : _("WWW Daemon Apache"),
/* User name for user: "ftp" */
"FTP account" : _("FTP Account"),
/* User name for user: "named" */
"Nameserver daemon" : _("Name Server Daemon"),
/* User name for user: "gdm" */
"Gnome Display Manager daemon" : _("GNOME Display Manager Daemon"),
/* User name for user: "postfix" */
"Postfix Daemon" : _("Postfix Daemon"),
/* User name for user: "sshd" */
"SSH daemon" : _("SSH Daemon"),
/* User name for user: "ntp" */
"NTP daemon" : _("NTP Daemon"),
/* User name for user: "ldap" */
"User for OpenLDAP" : _("User for OpenLDAP"),
/* User name for user: "nobody" */
"nobody" : _("Nobody"),
/* User name for user: "amanda" */
"Amanda admin" : _("Amanda Admin"),
/* User name for user: "vscan" */
"Vscan account" : _("Vscan Account"),
/* User name for user: "bigsister" */
"Big Sister" : _("Big Sister"),
/* User name for user: "wnn" */
"Wnn System Account" : _("Wnn System Account"),
/* User name for user: "cyrus" */
"User for cyrus-imapd" : _("User for cyrus-imapd"),
/* User name for user: "dpbox" */
"DpBox account" : _("DpBox Account"),
/* User name for user: "gnats" */
"GNATS GNU Backtracking System" : _("GNATS GNU Backtracking System"),
/* User name for user: "gnump3d" */
"GNUMP3 daemon" : _("GNUMP3 Daemon"),
/* User name for user: "hacluster" */
"heartbeat processes" : _("Heartbeat Processes"),
/* User name for user: "irc" */
"IRC daemon" : _("IRC Daemon"),
/* User name for user: "mailman" */
"GNU mailing list manager" : _("GNU Mailing List Manager"),
/* User name for user: "mdom" */
"Mailing list agent" : _("Mailing List Agent"),
/* User name for user: "mysql" */
"MySQL database admin" : _("MySQL Database Admin"),
/* User name for user: "oracle" */
"Oracle user" : _("Oracle User"),
/* User name for user: "postgres" */
"PostgreSQL Server": _("PostgreSQL Server"),
/* User name for user: "pop" */
"POP admin" : _("POP Admin"),
/* User name for user: "sapdb" */
"SAPDB account" : _("SAPDB Account"),
/* User name for user: "snort" */
"Snort network monitor" : _("Snort Network Monitor"),
/* User name for user: "squid" */
"WWW-proxy squid" : _("WWW Proxy Squid"),
/* User name for user: "stunnel" */
"Daemon user for stunnel (universal SSL tunnel)" : _("Daemon User for stunnel (Universal SSL Tunnel)"),
/* User name for user: "zope" */
"Zope" : _("Zope"),
/* User name for user: "radiusd" */
"Radius daemon" : _("Radius Daemon"),
/* User name for user: "otrs" */
"OTRS System User" : _("OTRS System User"),
/* User name for user: "privoxy" */
"Daemon user for privoxy" : _("Daemon User for privoxy"),
/* User name for user: "vdr" */
"Video Disk Recorder" : _("Video Disk Recorder"),
/* User name for user: "icecream" */
"Icecream Daemon" : _("Icecream Daemon"),
/* User name for user: "bitlbee" */
"Bitlbee Daemon User" : _("Bitlbee Daemon User"),
/* User name for user: "dhcpd" */
"DHCP server daemon" : _("DHCP Server Daemon"),
/* User name for user: "distcc" */
"Distcc Daemon" : _("Distcc Daemon"),
/* User name for user: "dovecot" */
"Dovecot imap daemon" : _("Dovecot IMAP Daemon"),
/* User name for user: "fax" */
"Facsimile agent" : _("Facsimile Agent"),
/* User name for user: "partimag" */
"Partimage Daemon User" : _("Partimage Daemon User"),
// User name for user: "avahi"
"User for Avahi" : _("User for Avahi"),
// User name for user: "beagleindex"
"User for Beagle indexing" : _("User for Beagle indexing"),
// User name for user: "casaauth"
"casa_atvd System User" : _("casa_atvd System User"),
// User name for user: "dvbdaemon"
"User for DVB daemon" : _("User for DVB daemon"),
// User name for user: "festival"
"Festival daemon" : _("Festival daemon"),
// User name for user: "haldaemon"
"User for haldaemon" : _("User for haldaemon"),
// User name for user: "icecast"
"Icecast streaming server" : _("Icecast streaming server"),
// User name for user: "lighttpd"
"user for lighttpd" : _("user for lighttpd"),
// User name for user: "nagios"
"User for Nagios" : _("User for Nagios"),
// User name for user: "pdns"
"pdns" : _("User for PowerDNS"),
// User name for user: "polkituser"
"PolicyKit" : _("PolicyKit"),
// User name for user: "pound"
"Pound" : _("User for Pound"),
// User name for user: "pulse"
"PulseAudio daemon" : _("PulseAudio daemon"),
// User name for user: "quagga"
"Quagga routing daemon" : _("Quagga routing daemon"),
// User name for user: "sabayon-admin"
"Sabayon user" : _("Sabayon user"),
// User name for user: "tomcat"
"Tomcat - Apache Servlet/JSP Engine" : _("Tomcat - Apache Servlet/JSP Engine"),
// User name for user: "tomcat"
"Apache Tomcat" : _("Apache Tomcat"),
// User name for user: "pegasus"
// User name for user: "cimsrvr"
"tog-pegasus OpenPegasus WBEM/CIM services" : _("tog-pegasus OpenPegasus WBEM/CIM services"),
// User name for user: "ulogd"
"ulog daemon" : _("ulog daemon"),
// User name for user: "uuidd"
"User for uuidd" : _("User for uuidd"),
// User name for user: "suse-ncc"
"Novell Customer Center User" : _("Novell Customer Center User"),
];
return SystemUsers[name]:name;
}
/**
* Ask user for configuration type (standard or NIS)
* @param dir string directory with NIS settings
* @return symbol `passwd or `nis or `abort
*/
define symbol getConfigurationType (string dir) ``{
term contents = `VBox (
// label
`Label (_("You have installed a NIS master server.
It is configured to use a different database
of users and groups than the local system
database in the /etc directory.
Select which one to configure.
")),
`VSpacing (1),
`RadioButtonGroup (`id (`configtype), `VBox (
// radio button
`RadioButton (`id (`passwd), `opt (`hstretch), _("&Local (/etc directory)"), true),
`VSpacing (1),
// radio button, %1 is path (eg. /etc)
`RadioButton (`id (`nis), `opt (`hstretch), sformat(_("&NIS (%1 directory)"), dir), false)
)),
`VSpacing (1),
`HBox (
`HStretch (),
`PushButton (`id (`ok), `opt(`default), Label::OKButton()),
`HStretch (),
`PushButton (`id (`abort), Label::AbortButton()),
`HStretch ()
)
);
UI::OpenDialog (contents);
symbol ret = nil;
while (ret == nil)
{
ret = (symbol) UI::UserInput ();
if (ret != `cancel && ret != `ok)
continue;
}
if (ret == `ok)
ret = (symbol) UI::QueryWidget (`id (`configtype), `CurrentButton);
UI::CloseDialog ();
return ret;
}
/**
* If we can ask and are a NIS server, ask which set of users
* to administer and set UserWriteStack accordingly.
* @param basedir the directory, where the data are stored
* @return directory
*/
global define string ReadNISConfigurationType (string basedir)``{
string ypdir = (string)SCR::Read(.sysconfig.ypserv.YPPWD_SRCDIR);
while (substring (ypdir, size (ypdir) - 1) == "/")
{
ypdir = substring (ypdir, 0, size (ypdir) -1);
}
if (ypdir == "" || ypdir == nil)
ypdir = basedir;
if (ypdir != basedir)
{
symbol type = getConfigurationType (ypdir);
if (type == `abort)
{
return nil;
}
if (type != `nis)
{
ypdir = basedir;
}
}
return ypdir;
}
global define map ChooseTemplates (list<string> user_templates, list<string> group_templates)``{
string user_template = user_templates[0]:"";
string group_template = group_templates[0]:"";
// label above radiobutton box
term rbu_buttons = `VBox( `Left(`Label (_("User Templates"))));
// label above radiobutton box
term rbg_buttons = `VBox( `Left(`Label (_("Group Templates"))));
foreach (string templ, user_templates, ``{
rbu_buttons = add (rbu_buttons,
`Left(`RadioButton (`id(templ), templ, true)));
});
foreach (string templ, group_templates, ``{
rbg_buttons = add (rbg_buttons,
`Left(`RadioButton (`id(templ), templ, true)));
});
term rb_users = `RadioButtonGroup (`id(`rbu), rbu_buttons);
term rb_groups = `RadioButtonGroup (`id(`rbg), rbg_buttons);
UI::OpenDialog (`opt(`decorated), `HBox (`HSpacing (1),
`VBox(
`HSpacing(50),
`VSpacing (0.5),
// label
`Label (_("Multiple templates are defined as default. Select the one to read.")),
`VSpacing (0.5),
user_templates == [] ? `Empty(): rb_users,
`VSpacing (0.5),
group_templates == [] ? `Empty() : rb_groups,
`HBox(
`PushButton (`id(`ok),`opt(`default), Label::OKButton()),
`PushButton (`id(`cancel), Label::CancelButton())
)),
`HSpacing (1))
);
any ret = UI::UserInput();
if (ret == `ok)
{
if (user_templates != [])
user_template = (string) UI::QueryWidget (`id(`rbu), `CurrentButton);
if (group_templates != [])
group_template = (string)UI::QueryWidget (`id(`rbg), `CurrentButton);
}
UI::CloseDialog();
return $[
"user" : user_template,
"group" : user_template,
];
}
/**
* Error messages for errors detected during reading via .passwd agent
* @param error number returned by passwd-agent
* @return error message
*/
global define string GetPasswdErrorMessage (integer errno, string more) ``{
string last =
// error message 2/2 (= next sentence)
_("Correct them manually before running the YaST users module again.");
map read_error = $[
2: sformat(
// error message 1/2: %1 is file name, %2 is username, %3 is next sentence (2/2)
_("There are multiple users with the same name (\"%2\") in the file %1.
%3"), "/etc/passwd", more, last),
3: sformat(
// error message 1/2: %1 is file name, %2 is username, %3 is next sentence (2/2)
_("There are multiple users with the same name (\"%2\") in the file %1.
%3"), "/etc/shadow", more, last),
6: sformat(
// error message 1/2: %1 is file name, %2 is groupname, %3 next sentence (2/2)
_("There are multiple groups with the same name (\"%2\") in the file %1.
%3"), "/etc/group", more, last),
7: sformat(
// error message 1/2: %1 is file name, %2 is line
_("There is a strange line in the file %1:
%2
Perhaps the number of colons is wrong or some line entry is missing.
Correct the file manually before running the YaST users module again."),
"/etc/passwd", more),
8: sformat(
// error message 1/2: %1 is file name, %2 is line
_("There is a strange line in the file %1:
%2
Perhaps the number of colons is wrong or some line entry is missing.
Correct the file manually before running the YaST users module again."),
"/etc/group", more),
9: sformat(
// error message 1/2: %1 is file name
_("There is a strange line in the file %1.
Perhaps the number of colons is wrong or some line entry is missing.
Correct the file manually before running the YaST users module again."),
"/etc/shadow"),
];
// default error message
return read_error[errno]: _("Cannot read user or group data.");
}
/**
* recode the string from "environment encoding" to UTF-8
*/
global define string RecodeUTF (string text) ``{
return (string) UI::Recode (WFM::GetEnvironmentEncoding(), "UTF-8",text);
}
/**
*/
global define string HashPassword (string method, string pw) ``{
if (method == "md5")
return cryptmd5 (pw);
if (method == "blowfish")
return cryptblowfish (pw);
return crypt (pw);
}
}//EOF
ACC SHELL 2018