New upstream version 4.17.0

This commit is contained in:
Chris Hofstaedtler
2024-12-28 13:12:23 +01:00
parent f78a468368
commit c2a3ebed18
423 changed files with 1574 additions and 1181 deletions
+3 -3
View File
@@ -225,7 +225,7 @@ static char *copy_field (char *in, char *out, char *extra)
break;
if (NULL != extra) {
if ('\0' != extra[0]) {
if (!streq(extra, "")) {
strcat (extra, ",");
}
@@ -543,7 +543,7 @@ static void get_old_fields (const char *gecos)
* Anything left over is "slop".
*/
if ((NULL != cp) && !oflg) {
if ('\0' != slop[0]) {
if (!streq(slop, "")) {
strcat (slop, ",");
}
@@ -702,7 +702,7 @@ int main (int argc, char **argv)
}
SNPRINTF(new_gecos, "%s,%s,%s,%s%s%s",
fullnm, roomno, workph, homeph,
('\0' != slop[0]) ? "," : "", slop);
(!streq(slop, "")) ? "," : "", slop);
/* Rewrite the user's gecos in the passwd file */
update_gecos (user, new_gecos);
+1 -1
View File
@@ -179,7 +179,7 @@ static bool is_valid_user_list (const char *users)
tmpusers = dup = xstrdup(users);
while (NULL != tmpusers && '\0' != *tmpusers) {
while (NULL != tmpusers && !streq(tmpusers, "")) {
const char *u;
u = strsep(&tmpusers, ",");
+2 -1
View File
@@ -580,7 +580,8 @@ static void check_grp_file (int *errors, bool *changed)
*/
if ( (NULL != grp->gr_mem[0])
&& (NULL == grp->gr_mem[1])
&& ('\0' == grp->gr_mem[0][0])) {
&& streq(grp->gr_mem[0], ""))
{
grp->gr_mem[0] = NULL;
}
+12 -1
View File
@@ -61,6 +61,7 @@ static bool tflg = false; /* print is restricted to most recent days */
static bool bflg = false; /* print excludes most recent days */
static bool Cflg = false; /* clear record for user */
static bool Sflg = false; /* set record for user */
static bool aflg = false; /* print only users that have logged in */
#define NOW time(NULL)
@@ -81,6 +82,7 @@ usage (int status)
(void) fputs (_(" -S, --set set lastlog record to current time (usable only with -u)\n"), usageout);
(void) fputs (_(" -t, --time DAYS print only lastlog records more recent than DAYS\n"), usageout);
(void) fputs (_(" -u, --user LOGIN print lastlog record of the specified LOGIN\n"), usageout);
(void) fputs (_(" -a, --active print lastlog excluding '**Never logged in**' users"), usageout);
(void) fputs ("\n", usageout);
exit (status);
}
@@ -165,6 +167,9 @@ static void print_one (/*@null@*/const struct passwd *pw)
cp = ptime;
}
if (ll.ll_time == (time_t) 0) {
/* If aflg is used,i.e aflag=true omit the 'Never logged in' lines */
if (aflg)
return;
cp = _("**Never logged in**\0");
}
@@ -319,10 +324,11 @@ int main (int argc, char **argv)
{"set", no_argument, NULL, 'S'},
{"time", required_argument, NULL, 't'},
{"user", required_argument, NULL, 'u'},
{"active", no_argument, NULL, 'a'},
{NULL, 0, NULL, '\0'}
};
while ((c = getopt_long (argc, argv, "b:ChR:St:u:", longopts,
while ((c = getopt_long (argc, argv, "b:ChR:St:u:a", longopts,
NULL)) != -1) {
switch (c) {
case 'b':
@@ -396,6 +402,11 @@ int main (int argc, char **argv)
}
break;
}
case 'a':
{
aflg = true;
break;
}
default:
usage (EXIT_FAILURE);
/*@notreached@*/break;
+7 -7
View File
@@ -422,7 +422,7 @@ static /*@observer@*/const char *get_failent_user (/*@returned@*/const char *use
const char *failent_user = "UNKNOWN";
bool log_unkfail_enab = getdef_bool("LOG_UNKFAIL_ENAB");
if ((NULL != user) && ('\0' != user[0])) {
if ((NULL != user) && !streq(user, "")) {
if ( log_unkfail_enab
|| (getpwnam (user) != NULL)) {
failent_user = user;
@@ -589,13 +589,13 @@ int main (int argc, char **argv)
if (hflg) {
cp = hostname;
} else if ((host != NULL) && (host[0] != '\0')) {
} else if ((host != NULL) && !streq(host, "")) {
cp = host;
} else {
cp = "";
}
if ('\0' != *cp) {
if (!streq(cp, "")) {
SNPRINTF(fromhost, " on '%.100s' from '%.200s'", tty, cp);
} else {
SNPRINTF(fromhost, " on '%.100s'", tty);
@@ -661,7 +661,7 @@ int main (int argc, char **argv)
/* if we didn't get a user on the command line,
set it to NULL */
get_pam_user (&pam_user);
if ((NULL != pam_user) && ('\0' == pam_user[0])) {
if ((NULL != pam_user) && streq(pam_user, "")) {
retcode = pam_set_item (pamh, PAM_USER, NULL);
PAM_FAIL_CHECK;
}
@@ -838,7 +838,7 @@ int main (int argc, char **argv)
username = XMALLOC(max_size, char);
login_prompt(username, max_size);
if ('\0' == username[0]) {
if (streq(username, "")) {
/* Prompt for a new login */
free (username);
username = NULL;
@@ -925,7 +925,7 @@ int main (int argc, char **argv)
failed = true;
}
if ( !failed
&& !login_access (username, ('\0' != *hostname) ? hostname : tty)) {
&& !login_access(username, (!streq(hostname, "")) ? hostname : tty)) {
SYSLOG ((LOG_WARN, "LOGIN '%s' REFUSED %s",
username, fromhost));
failed = true;
@@ -963,7 +963,7 @@ int main (int argc, char **argv)
* guys won't see that the passwordless account exists at
* all). --marekm
*/
if (user_passwd[0] == '\0') {
if (streq(user_passwd, "")) {
pw_auth ("!", username, reason, NULL);
}
+15 -14
View File
@@ -29,7 +29,6 @@
#ifndef USE_PAM
#ident "$Id$"
#include "prototypes.h"
/*
* This module implements a simple but effective form of login access
* control based on login names and on host (or domain) names, internet
@@ -38,27 +37,29 @@
*
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
*/
#include <sys/types.h>
#include <stddef.h>
#include <stdio.h>
#include <syslog.h>
#include <arpa/inet.h> /* for inet_ntoa() */
#include <ctype.h>
#include <netdb.h>
#include <errno.h>
#include <grp.h>
#include <netdb.h>
#include <netinet/in.h>
#ifdef PRIMARY_GROUP_MATCH
#include <pwd.h>
#endif
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h> /* for inet_ntoa() */
#include <sys/types.h>
#include <syslog.h>
#include <unistd.h>
#include "prototypes.h"
#include "sizeof.h"
#include "string/strchr/strrspn.h"
#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
@@ -110,7 +111,7 @@ login_access(const char *user, const char *from)
continue; /* comment line */
}
stpcpy(strrspn(line, " \t"), "");
if (line[0] == '\0') { /* skip blank lines */
if (streq(line, "")) { /* skip blank lines */
continue;
}
p = line;
@@ -182,7 +183,7 @@ static char *myhostname (void)
{
static char name[MAXHOSTNAMELEN + 1] = "";
if (name[0] == '\0') {
if (streq(name, "")) {
gethostname (name, sizeof (name));
stpcpy(&name[MAXHOSTNAMELEN], "");
}
@@ -319,7 +320,7 @@ static bool from_match (const char *tok, const char *string)
if (strchr (string, '.') == NULL) {
return true;
}
} else if ( (tok[0] != '\0' && tok[(tok_len = strlen (tok)) - 1] == '.') /* network */
} else if ( (!streq(tok, "") && tok[(tok_len = strlen(tok)) - 1] == '.') /* network */
&& (strncmp (tok, resolve_hostname (string), tok_len) == 0)) {
return true;
}
+4 -4
View File
@@ -150,7 +150,7 @@ static void check_perms (const struct group *grp,
spw_free (spwd);
}
if ((pwd->pw_passwd[0] == '\0') && (grp->gr_passwd[0] != '\0')) {
if (streq(pwd->pw_passwd, "") && !streq(grp->gr_passwd, "")) {
needspasswd = true;
}
@@ -188,8 +188,8 @@ static void check_perms (const struct group *grp,
goto failure;
}
if (grp->gr_passwd[0] == '\0' ||
!streq(cpasswd, grp->gr_passwd)) {
if (streq(grp->gr_passwd, "") ||
!streq(grp->gr_passwd, cpasswd)) {
#ifdef WITH_AUDIT
SNPRINTF(audit_buf, "authentication new-gid=%lu",
(unsigned long) grp->gr_gid);
@@ -786,7 +786,7 @@ int main (int argc, char **argv)
cp = getenv ("SHELL");
if (!initflag && (NULL != cp)) {
prog = cp;
} else if ((NULL != pwd->pw_shell) && ('\0' != pwd->pw_shell[0])) {
} else if ((NULL != pwd->pw_shell) && !streq(pwd->pw_shell, "")) {
prog = pwd->pw_shell;
} else {
prog = SHELL;
+6 -6
View File
@@ -282,7 +282,7 @@ static int add_group (const char *name, const char *gid, gid_t *ngid, uid_t uid)
/*
* Now I have all of the fields required to create the new group.
*/
if (('\0' != gid[0]) && (!isdigit (gid[0]))) {
if (!streq(gid, "") && (!isdigit(gid[0]))) {
grent.gr_name = xstrdup (gid);
} else {
grent.gr_name = xstrdup (name);
@@ -355,7 +355,7 @@ static int get_user_id (const char *uid, uid_t *nuid) {
return -1;
}
} else {
if ('\0' != uid[0]) {
if (!streq(uid, "")) {
const struct passwd *pwd;
/* local, no need for xgetpwnam */
pwd = getpwnam (uid);
@@ -1222,19 +1222,19 @@ int main (int argc, char **argv)
Prog, line);
fail_exit (EXIT_FAILURE);
}
if ('\0' != fields[4][0]) {
if (!streq(fields[4], "")) {
newpw.pw_gecos = fields[4];
}
if ('\0' != fields[5][0]) {
if (!streq(fields[5], "")) {
newpw.pw_dir = fields[5];
}
if ('\0' != fields[6][0]) {
if (!streq(fields[6], "")) {
newpw.pw_shell = fields[6];
}
if ( ('\0' != fields[5][0])
if ( !streq(fields[5], "")
&& (access (newpw.pw_dir, F_OK) != 0)) {
/* FIXME: should check for directory */
mode_t mode = getdef_num ("HOME_MODE",
+2 -2
View File
@@ -194,7 +194,7 @@ static int new_password (const struct passwd *pw)
* password.
*/
if (!amroot && ('\0' != crypt_passwd[0])) {
if (!amroot && !streq(crypt_passwd, "")) {
clear = agetpass (_("Old password: "));
if (NULL == clear) {
return -1;
@@ -441,7 +441,7 @@ static /*@observer@*/const char *pw_status (const char *pass)
if (*pass == '*' || *pass == '!') {
return "L";
}
if (*pass == '\0') {
if (streq(pass, "")) {
return "NP";
}
return "P";
+1 -1
View File
@@ -533,7 +533,7 @@ static void check_pw_file (int *errors, bool *changed)
* Make sure the login shell is executable
*/
if ( !quiet
&& ('\0' != pwd->pw_shell[0])
&& !streq(pwd->pw_shell, "")
&& (access (pwd->pw_shell, F_OK) != 0)) {
/*
+5 -5
View File
@@ -862,7 +862,7 @@ static void process_flags (int argc, char **argv)
if (optind < argc) {
STRTCPY(name, argv[optind++]); /* use this login id */
}
if ('\0' == name[0]) { /* use default user */
if (streq(name, "")) { /* use default user */
struct passwd *root_pw = getpwnam ("root");
if ((NULL != root_pw) && (0 == root_pw->pw_uid)) {
(void) strcpy (name, "root");
@@ -1080,15 +1080,15 @@ int main (int argc, char **argv)
/*
* Set the default shell.
*/
if ((NULL == shellstr) || ('\0' == shellstr[0])) {
if ((NULL == shellstr) || streq(shellstr, "")) {
shellstr = SHELL;
}
sulog (caller_tty, true, caller_name, name); /* save SU information */
if (getdef_bool ("SYSLOG_SU_ENAB")) {
SYSLOG ((LOG_INFO, "+ %s %s:%s", caller_tty,
('\0' != caller_name[0]) ? caller_name : "???",
('\0' != name[0]) ? name : "???"));
(!streq(caller_name, "")) ? caller_name : "???",
(!streq(name, "")) ? name : "???"));
}
#ifdef USE_PAM
@@ -1143,7 +1143,7 @@ int main (int argc, char **argv)
AUDIT_USER_ROLE_CHANGE,
NULL, /* Prog. name */
"su",
('\0' != caller_name[0]) ? caller_name : "???",
(!streq(caller_name, "")) ? caller_name : "???",
AUDIT_NO_ID,
"localhost",
NULL, /* addr */
+1 -1
View File
@@ -86,7 +86,7 @@ check_su_auth(const char *actual_id, const char *wanted_id, bool su_to_root)
stpcpy(strrspn(temp, " \t"), "");
p = stpspn(temp, " \t");
if (*p == '#' || *p == '\0')
if (*p == '#' || streq(p, ""))
continue;
to_users = strsep(&p, ":");
+2 -1
View File
@@ -27,6 +27,7 @@
/*@-exitarg@*/
#include "exitcodes.h"
#include "shadowlog.h"
#include "string/strcmp/streq.h"
#include "string/strdup/xstrdup.h"
@@ -153,7 +154,7 @@ main(int argc, char *argv[])
* it will work with standard getpass() (no NULL on EOF).
* --marekm
*/
if ((NULL == pass) || ('\0' == *pass)) {
if ((NULL == pass) || streq(pass, "")) {
erase_pass (pass);
(void) puts ("");
#ifdef TELINIT
+9 -9
View File
@@ -177,7 +177,7 @@ static bool
Uflg = false; /* create a group having the same name as the user */
#ifdef WITH_SELINUX
#define Zflg ('\0' != *user_selinux)
#define Zflg (!streq(user_selinux, ""))
#endif /* WITH_SELINUX */
static bool home_added = false;
@@ -439,7 +439,7 @@ get_defaults(void)
* Default Skeleton information
*/
else if (streq(buf, DSKEL)) {
if ('\0' == *ccp)
if (streq(ccp, ""))
ccp = SKEL_DIR;
if (prefix[0]) {
@@ -456,7 +456,7 @@ get_defaults(void)
* Default Usr Skeleton information
*/
else if (streq(buf, DUSRSKEL)) {
if ('\0' == *ccp)
if (streq(ccp, ""))
ccp = USRSKELDIR;
if (prefix[0]) {
@@ -472,7 +472,7 @@ get_defaults(void)
* Create by default user mail spool or not ?
*/
else if (streq(buf, DCREATE_MAIL_SPOOL)) {
if (*ccp == '\0')
if (streq(ccp, ""))
ccp = "no";
def_create_mail_spool = xstrdup(ccp);
@@ -482,7 +482,7 @@ get_defaults(void)
* By default do we add the user to the lastlog and faillog databases ?
*/
else if (streq(buf, DLOG_INIT)) {
if (*ccp == '\0')
if (streq(ccp, ""))
ccp = def_log_init;
def_log_init = xstrdup(ccp);
@@ -770,7 +770,7 @@ static int get_groups (char *list)
user_groups[i++] = NULL;
}
if ('\0' == *list) {
if (streq(list, "")) {
return 0;
}
@@ -1268,7 +1268,7 @@ static void process_flags (int argc, char **argv)
Dflg = true;
break;
case 'e':
if ('\0' != *optarg) {
if (!streq(optarg, "")) {
user_expire = strtoday (optarg);
if (user_expire < -1) {
fprintf (stderr,
@@ -1403,7 +1403,7 @@ static void process_flags (int argc, char **argv)
break;
case 's':
if ( ( !VALID (optarg) )
|| ( ('\0' != optarg[0])
|| ( !streq(optarg, "")
&& ('/' != optarg[0])
&& ('*' != optarg[0]) )) {
fprintf (stderr,
@@ -1411,7 +1411,7 @@ static void process_flags (int argc, char **argv)
Prog, optarg);
exit (E_BAD_ARG);
}
if ( '\0' != optarg[0]
if (!streq(optarg, "")
&& '*' != optarg[0]
&& !streq(optarg, "/sbin/nologin")
&& ( stat(optarg, &st) != 0
+2 -2
View File
@@ -1131,7 +1131,7 @@ int main (int argc, char **argv)
* Note: This is a best effort basis. The user may log in between,
* a cron job may be started on her behalf, etc.
*/
if ((prefix[0] == '\0') && !Rflg && user_busy (user_name, user_id) != 0) {
if (streq(prefix, "") && !Rflg && user_busy(user_name, user_id) != 0) {
if (!fflg) {
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
@@ -1264,7 +1264,7 @@ int main (int argc, char **argv)
* Cancel any crontabs or at jobs. Have to do this before we remove
* the entry from /etc/passwd.
*/
if (prefix[0] == '\0')
if (streq(prefix, ""))
user_cancel (user_name);
close_files ();
+5 -5
View File
@@ -227,7 +227,7 @@ static int get_groups (char *list)
*/
user_groups[0] = NULL;
if ('\0' == *list) {
if (streq(list, "")) {
return 0;
}
@@ -1154,7 +1154,7 @@ process_flags(int argc, char **argv)
break;
case 's':
if ( ( !VALID (optarg) )
|| ( ('\0' != optarg[0])
|| ( !streq(optarg, "")
&& ('/' != optarg[0])
&& ('*' != optarg[0]) )) {
fprintf (stderr,
@@ -1162,7 +1162,7 @@ process_flags(int argc, char **argv)
Prog, optarg);
exit (E_BAD_ARG);
}
if ( '\0' != optarg[0]
if (!streq(optarg, "")
&& '*' != optarg[0]
&& !streq(optarg, "/sbin/nologin")
&& ( stat(optarg, &st) != 0
@@ -2186,7 +2186,7 @@ int main (int argc, char **argv)
* be changed while the user is logged in.
* Note: no need to check if a prefix is specified...
*/
if ( (prefix[0] == '\0') && (uflg || lflg || dflg
if (streq(prefix, "") && (uflg || lflg || dflg
#ifdef ENABLE_SUBIDS
|| Vflg || Wflg
#endif /* ENABLE_SUBIDS */
@@ -2334,7 +2334,7 @@ int main (int argc, char **argv)
#ifdef WITH_SELINUX
if (Zflg) {
if ('\0' != *user_selinux) {
if (!streq(user_selinux, "")) {
if (set_seuser (user_name, user_selinux, user_selinux_range) != 0) {
fprintf (stderr,
_("%s: warning: the user name %s to %s SELinux user mapping failed.\n"),