]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: use HUSHLOGIN_FILE from login.defs
authorKarel Zak <kzak@redhat.com>
Wed, 5 Oct 2011 21:39:14 +0000 (23:39 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 26 Oct 2011 21:17:17 +0000 (23:17 +0200)
Note that Suse login(1) does not use any default for HUSHLOGIN_FILE.
We use /etc/hushlogins and ~/.hushlogin as default.

The another difference is that *empty* global (e.g. /etc/hushlogins)
means that hushed mode will be enabled for all accounts.

Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.1
login-utils/login.c

index cce4672316ad13aa317f963d2ea0e6e67e97c555..c72fcfa9677127639e49f50679314152aa662ced 100644 (file)
@@ -158,7 +158,23 @@ then the ownership of the terminal is set to the user\'s primary group.
 .SP
 The \fBTTYGROUP\fR can be either the name of a group or a numeric group identifier.
 .RE
+.PP
+\fBHUSHLOGIN_FILE\fR (string)
+.RS 4
+If defined, this file can inhibit all the usual chatter during the login
+sequence.  If a full pathname (e.g. /etc/hushlogins) is specified, then hushed
+mode will be enabled if the user\'s name or shell are found in the file. If
+this global hush login file is empty then the hushed mode will be enabled for
+all users.
+
+If not a full pathname is specified, then hushed mode will be enabled if the
+file exists in the user\'s home directory.
 
+The default is to check "/etc/hushlogins" and if does not exist then
+"~/.hushlogin".
+
+If the \fBHUSHLOGIN_FILE\fR item is empty then all checks are disabled.
+.RE
 .SH FILES
 .nf
 .I /var/run/utmp
index 17a3137108a55dc1a3afd61e0e5578052e54a9be..1c6707726ecfe7c3364dcd004722b81a2ee772ab 100644 (file)
@@ -845,6 +845,8 @@ static int effective_access(const char *path, int mode)
  *
  * The ~/.hushlogin is ignored if the global hush file exists.
  *
+ * The HUSHLOGIN_FILE login.def variable overwrites the default hush filename.
+ *
  * Note that shadow-utils login(1) does not support "a1)". The "a1)" is
  * necessary if you want to use PAM for "Last login" message.
  *
@@ -862,13 +864,24 @@ static int effective_access(const char *path, int mode)
 static int get_hushlogin_status(struct passwd *pwd)
 {
        const char *files[] = { _PATH_HUSHLOGINS, _PATH_HUSHLOGIN, NULL };
+       const char *file;
        char buf[BUFSIZ];
        int i;
 
+       file = getlogindefs_str("HUSHLOGIN_FILE", NULL);
+       if (file) {
+               if (!*file)
+                       return 0;       /* empty HUSHLOGIN_FILE defined */
+
+               files[0] = file;
+               files[1] = NULL;
+       }
+
        for (i = 0; files[i]; i++) {
-               const char *file = files[i];
                int ok = 0;
 
+               file = files[i];
+
                /* Global hush-file*/
                if (*file == '/') {
                        struct stat st;