From: Tobias Stoeckmann Date: Tue, 16 Dec 2025 21:59:59 +0000 (+0100) Subject: lib/, src/: Fix formatting X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5369ad7566dcfedad79404cba87b8dd19ea5fa63;p=thirdparty%2Fshadow.git lib/, src/: Fix formatting Fix places where spaces were used instead of tabs. No functional change. Signed-off-by: Tobias Stoeckmann --- diff --git a/lib/atoi/a2i.h b/lib/atoi/a2i.h index 74a34a282..6d67496fe 100644 --- a/lib/atoi/a2i.h +++ b/lib/atoi/a2i.h @@ -23,9 +23,9 @@ QChar_of(s) **endp_ = endp; \ T min_ = min; \ T max_ = max; \ - \ + \ int status; \ - \ + \ *n_ = _Generic((T){}, \ short: strtoi_, \ int: strtoi_, \ @@ -36,7 +36,7 @@ unsigned long: strtou_noneg, \ unsigned long long: strtou_noneg \ )(s, (char **) endp_, base, min_, max_, &status); \ - \ + \ if (status != 0) \ errno = status; \ -!!status; \ diff --git a/lib/chkname.c b/lib/chkname.c index c8e0066d2..6abd34fff 100644 --- a/lib/chkname.c +++ b/lib/chkname.c @@ -64,14 +64,14 @@ is_valid_name(const char *name) } /* - * User/group names must match BRE regex: - * [a-zA-Z0-9_.][a-zA-Z0-9_.-]*$\? - * - * as a non-POSIX, extension, allow "$" as the last char for - * sake of Samba 3.x "add machine script" - * - * Also do not allow fully numeric names or just "." or "..". - */ + * User/group names must match BRE regex: + * [a-zA-Z0-9_.][a-zA-Z0-9_.-]*$\? + * + * as a non-POSIX, extension, allow "$" as the last char for + * sake of Samba 3.x "add machine script" + * + * Also do not allow fully numeric names or just "." or "..". + */ if (strisdigit(name)) { errno = EINVAL; diff --git a/lib/commonio.h b/lib/commonio.h index 2e86d561d..8507e0e47 100644 --- a/lib/commonio.h +++ b/lib/commonio.h @@ -94,7 +94,7 @@ struct commonio_db { #endif /* * Default permissions and owner for newly created data file. - */ + */ mode_t st_mode; uid_t st_uid; gid_t st_gid; diff --git a/lib/copydir.c b/lib/copydir.c index 27bc1a630..796015afb 100644 --- a/lib/copydir.c +++ b/lib/copydir.c @@ -501,14 +501,14 @@ static int copy_dir (const struct path_info *src, const struct path_info *dst, return -1; } #endif /* WITH_SELINUX */ - /* - * If the destination is already a directory, don't change it - * but copy into it (recursively). - */ - if (fstatat(dst->dirfd, dst->name, &dst_sb, AT_SYMLINK_NOFOLLOW) == 0 && S_ISDIR(dst_sb.st_mode)) { - return (copy_tree_impl (src, dst, false, reset_selinux, - old_uid, new_uid, old_gid, new_gid) != 0); - } + /* + * If the destination is already a directory, don't change it + * but copy into it (recursively). + */ + if (fstatat(dst->dirfd, dst->name, &dst_sb, AT_SYMLINK_NOFOLLOW) == 0 && S_ISDIR(dst_sb.st_mode)) { + return (copy_tree_impl (src, dst, false, reset_selinux, + old_uid, new_uid, old_gid, new_gid) != 0); + } if ( (mkdirat (dst->dirfd, dst->name, 0700) != 0) || (chownat_if_needed (dst, statp, @@ -798,7 +798,7 @@ static int chown_function ## _if_needed (type_dst dst, \ { \ uid_t tmpuid = (uid_t) -1; \ gid_t tmpgid = (gid_t) -1; \ - \ + \ /* Use new_uid if old_uid is set to -1 or if the file was \ * owned by the user. */ \ if (((uid_t) -1 == old_uid) || (statp->st_uid == old_uid)) { \ @@ -809,14 +809,14 @@ static int chown_function ## _if_needed (type_dst dst, \ if ((uid_t) -1 == tmpuid) { \ tmpuid = statp->st_uid; \ } \ - \ + \ if (((gid_t) -1 == old_gid) || (statp->st_gid == old_gid)) { \ tmpgid = new_gid; \ } \ if ((gid_t) -1 == tmpgid) { \ tmpgid = statp->st_gid; \ } \ - \ + \ return chown_function (dst, tmpuid, tmpgid); \ } diff --git a/lib/exit_if_null.h b/lib/exit_if_null.h index 708908b5b..6045bbcd1 100644 --- a/lib/exit_if_null.h +++ b/lib/exit_if_null.h @@ -26,7 +26,7 @@ #define exit_if_null(p) \ ({ \ __auto_type p_ = p; \ - \ + \ exit_if_null_(p_); \ p_; \ }) diff --git a/lib/find_new_gid.c b/lib/find_new_gid.c index dfcc9143d..a716445a5 100644 --- a/lib/find_new_gid.c +++ b/lib/find_new_gid.c @@ -56,11 +56,11 @@ static int get_ranges (bool sys_group, gid_t *min_id, gid_t *max_id, /* Check that the ranges make sense */ if (*max_id < *min_id) { (void) fprintf (log_get_logfd(), - _("%s: Invalid configuration: SYS_GID_MIN (%lu), " - "GID_MIN (%lu), SYS_GID_MAX (%lu)\n"), - log_get_progname(), (unsigned long) *min_id, - getdef_ulong ("GID_MIN", 1000UL), - (unsigned long) *max_id); + _("%s: Invalid configuration: SYS_GID_MIN (%lu), " + "GID_MIN (%lu), SYS_GID_MAX (%lu)\n"), + log_get_progname(), (unsigned long) *min_id, + getdef_ulong ("GID_MIN", 1000UL), + (unsigned long) *max_id); return EINVAL; } /* diff --git a/lib/find_new_uid.c b/lib/find_new_uid.c index 3cafef603..d2e9d1f69 100644 --- a/lib/find_new_uid.c +++ b/lib/find_new_uid.c @@ -55,11 +55,11 @@ static int get_ranges (bool sys_user, uid_t *min_id, uid_t *max_id, /* Check that the ranges make sense */ if (*max_id < *min_id) { (void) fprintf (log_get_logfd(), - _("%s: Invalid configuration: SYS_UID_MIN (%lu), " - "UID_MIN (%lu), SYS_UID_MAX (%lu)\n"), - log_get_progname(), (unsigned long) *min_id, - getdef_ulong ("UID_MIN", 1000UL), - (unsigned long) *max_id); + _("%s: Invalid configuration: SYS_UID_MIN (%lu), " + "UID_MIN (%lu), SYS_UID_MAX (%lu)\n"), + log_get_progname(), (unsigned long) *min_id, + getdef_ulong ("UID_MIN", 1000UL), + (unsigned long) *max_id); return EINVAL; } /* diff --git a/lib/logind.c b/lib/logind.c index b1ed632bb..3ba3341af 100644 --- a/lib/logind.c +++ b/lib/logind.c @@ -16,37 +16,37 @@ int get_session_host (char **out, pid_t main_pid) { - char *host = NULL; - char *session = NULL; - int ret; + char *host = NULL; + char *session = NULL; + int ret; - ret = sd_pid_get_session(main_pid, &session); - if (ret < 0) { - return ret; - } - ret = sd_session_get_remote_host (session, &host); - if (ret < 0) { - goto done; - } + ret = sd_pid_get_session(main_pid, &session); + if (ret < 0) { + return ret; + } + ret = sd_session_get_remote_host (session, &host); + if (ret < 0) { + goto done; + } - *out = host; + *out = host; done: - free (session); - return ret; + free (session); + return ret; } unsigned long active_sessions_count(const char *name, unsigned long) { - struct passwd *pw; - unsigned long count = 0; + struct passwd *pw; + unsigned long count = 0; - pw = prefix_getpwnam(name); - if (pw == NULL) { - return 0; - } + pw = prefix_getpwnam(name); + if (pw == NULL) { + return 0; + } - count = sd_uid_get_sessions(pw->pw_uid, 0, NULL); + count = sd_uid_get_sessions(pw->pw_uid, 0, NULL); - return count; + return count; } diff --git a/lib/string/strchr/strnul.h b/lib/string/strchr/strnul.h index 78bcdd9f3..4cb3b2ca6 100644 --- a/lib/string/strchr/strnul.h +++ b/lib/string/strchr/strnul.h @@ -18,7 +18,7 @@ #define strnul(s) \ ({ \ __auto_type s_ = s; \ - \ + \ s_ + strlen(s_); \ }) diff --git a/lib/string/strcmp/strcaseprefix.h b/lib/string/strcmp/strcaseprefix.h index 9982d1032..b001076b6 100644 --- a/lib/string/strcmp/strcaseprefix.h +++ b/lib/string/strcmp/strcaseprefix.h @@ -19,9 +19,9 @@ #define strcaseprefix(s, prefix) \ ({ \ const char *p_; \ - \ + \ p_ = strcaseprefix_(s, prefix); \ - \ + \ _Generic(s, \ const char *: p_, \ const void *: p_, \ diff --git a/lib/string/strcmp/strprefix.h b/lib/string/strcmp/strprefix.h index a9e438157..3abffb5f4 100644 --- a/lib/string/strcmp/strprefix.h +++ b/lib/string/strcmp/strprefix.h @@ -19,9 +19,9 @@ #define strprefix(s, prefix) \ ({ \ const char *p_; \ - \ + \ p_ = strprefix_(s, prefix); \ - \ + \ _Generic(s, \ const char *: p_, \ const void *: p_, \ diff --git a/lib/string/strspn/stprcspn.h b/lib/string/strspn/stprcspn.h index dc898787e..d9cf10773 100644 --- a/lib/string/strspn/stprcspn.h +++ b/lib/string/strspn/stprcspn.h @@ -17,7 +17,7 @@ #define stprcspn(s, reject) \ ({ \ __auto_type s_ = (s); \ - \ + \ s_ + strrcspn(s_, reject); \ }) diff --git a/lib/string/strspn/stprspn.h b/lib/string/strspn/stprspn.h index a7131b609..8684f9ef6 100644 --- a/lib/string/strspn/stprspn.h +++ b/lib/string/strspn/stprspn.h @@ -19,7 +19,7 @@ #define stprspn(s, accept) \ ({ \ __auto_type s_ = (s); \ - \ + \ s_ + strrspn_(s_, accept); \ }) diff --git a/lib/string/strspn/stpspn.h b/lib/string/strspn/stpspn.h index ccf9a343c..1834f5fcd 100644 --- a/lib/string/strspn/stpspn.h +++ b/lib/string/strspn/stpspn.h @@ -19,7 +19,7 @@ #define stpspn(s, accept) \ ({ \ __auto_type s_ = s; \ - \ + \ s_ + strspn(s_, accept); \ }) diff --git a/lib/subordinateio.c b/lib/subordinateio.c index b038379ef..b2cadfd02 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -198,74 +198,74 @@ static const struct subordinate_range *find_range(struct commonio_db *db, } - /* - * We only do special handling for these two files - */ - if (!streq(db->filename, SUBUID_FILE) && !streq(db->filename, SUBGID_FILE)) - return NULL; - - /* - * Search loop above did not produce any result. Let's rerun it, - * but this time try to match actual UIDs. The first entry that - * matches is considered a success. - * (It may be specified as literal UID or as another username which - * has the same UID as the username we are looking for.) - */ - char owner_uid_string[33]; - uid_t owner_uid; - struct passwd *pwd; - - - /* Get UID of the username we are looking for */ - pwd = getpwnam(owner); - if (NULL == pwd) { - /* Username not defined in /etc/passwd, or error occurred during lookup */ - return NULL; - } - owner_uid = pwd->pw_uid; - if (stprintf_a(owner_uid_string, "%lu", (unsigned long) owner_uid) == -1) - return NULL; - - commonio_rewind(db); - while (NULL != (range = commonio_next(db))) { - unsigned long first = range->start; - unsigned long last = first + range->count - 1; - - /* For performance reasons check range before using getpwnam() */ - if ((val < first) || (val > last)) { - continue; - } - - /* - * Range matches. Check if range owner is specified - * as numeric UID and if it matches. - */ - if (streq(range->owner, owner_uid_string)) { - return range; - } - - /* - * Ok, this range owner is not specified as numeric UID - * we are looking for. It may be specified as another - * UID or as a literal username. - * - * If specified as another UID, the call to getpwnam() - * will return NULL. - * - * If specified as literal username, we will get its - * UID and compare that to UID we are looking for. - */ - const struct passwd *range_owner_pwd; - - range_owner_pwd = getpwnam(range->owner); - if (NULL == range_owner_pwd) { - continue; - } - - if (owner_uid == range_owner_pwd->pw_uid) { - return range; - } - } + /* + * We only do special handling for these two files + */ + if (!streq(db->filename, SUBUID_FILE) && !streq(db->filename, SUBGID_FILE)) + return NULL; + + /* + * Search loop above did not produce any result. Let's rerun it, + * but this time try to match actual UIDs. The first entry that + * matches is considered a success. + * (It may be specified as literal UID or as another username which + * has the same UID as the username we are looking for.) + */ + char owner_uid_string[33]; + uid_t owner_uid; + struct passwd *pwd; + + + /* Get UID of the username we are looking for */ + pwd = getpwnam(owner); + if (NULL == pwd) { + /* Username not defined in /etc/passwd, or error occurred during lookup */ + return NULL; + } + owner_uid = pwd->pw_uid; + if (stprintf_a(owner_uid_string, "%lu", (unsigned long) owner_uid) == -1) + return NULL; + + commonio_rewind(db); + while (NULL != (range = commonio_next(db))) { + unsigned long first = range->start; + unsigned long last = first + range->count - 1; + + /* For performance reasons check range before using getpwnam() */ + if ((val < first) || (val > last)) { + continue; + } + + /* + * Range matches. Check if range owner is specified + * as numeric UID and if it matches. + */ + if (streq(range->owner, owner_uid_string)) { + return range; + } + + /* + * Ok, this range owner is not specified as numeric UID + * we are looking for. It may be specified as another + * UID or as a literal username. + * + * If specified as another UID, the call to getpwnam() + * will return NULL. + * + * If specified as literal username, we will get its + * UID and compare that to UID we are looking for. + */ + const struct passwd *range_owner_pwd; + + range_owner_pwd = getpwnam(range->owner); + if (NULL == range_owner_pwd) { + continue; + } + + if (owner_uid == range_owner_pwd->pw_uid) { + return range; + } + } return NULL; } diff --git a/src/chgpasswd.c b/src/chgpasswd.c index 9d87bb17b..38e9eae17 100644 --- a/src/chgpasswd.c +++ b/src/chgpasswd.c @@ -200,7 +200,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) #if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT) case 's': sflg = true; - bad_s = 0; + bad_s = 0; if (!crypt_method) { fprintf (stderr, @@ -211,22 +211,22 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) #if defined(USE_SHA_CRYPT) if ( ( (streq(crypt_method, "SHA256") || streq(crypt_method, "SHA512")) && (-1 == str2sl(&sha_rounds, optarg)))) { - bad_s = 1; - } + bad_s = 1; + } #endif /* USE_SHA_CRYPT */ #if defined(USE_BCRYPT) - if (( streq(crypt_method, "BCRYPT") + if ( ( streq(crypt_method, "BCRYPT") && (-1 == str2sl(&bcrypt_rounds, optarg)))) { - bad_s = 1; - } + bad_s = 1; + } #endif /* USE_BCRYPT */ #if defined(USE_YESCRYPT) - if (( streq(crypt_method, "YESCRYPT") + if ( ( streq(crypt_method, "YESCRYPT") && (-1 == str2sl(&yescrypt_cost, optarg)))) { - bad_s = 1; - } + bad_s = 1; + } #endif /* USE_YESCRYPT */ - if (bad_s != 0) { + if (bad_s != 0) { fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg); diff --git a/src/chpasswd.c b/src/chpasswd.c index b53660818..ea96dc749 100644 --- a/src/chpasswd.c +++ b/src/chpasswd.c @@ -159,7 +159,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) { int c; #if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT) - int bad_s; + int bad_s; #endif /* USE_SHA_CRYPT || USE_BCRYPT || USE_YESCRYPT */ static struct option long_options[] = { {"crypt-method", required_argument, NULL, 'c'}, @@ -203,26 +203,26 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) #if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT) case 's': sflg = true; - bad_s = 0; + bad_s = 0; #if defined(USE_SHA_CRYPT) if ((IS_CRYPT_METHOD("SHA256") || IS_CRYPT_METHOD("SHA512")) && (-1 == str2sl(&sha_rounds, optarg))) { - bad_s = 1; - } + bad_s = 1; + } #endif /* USE_SHA_CRYPT */ #if defined(USE_BCRYPT) - if (IS_CRYPT_METHOD("BCRYPT") + if (IS_CRYPT_METHOD("BCRYPT") && (-1 == str2sl(&bcrypt_rounds, optarg))) { - bad_s = 1; - } + bad_s = 1; + } #endif /* USE_BCRYPT */ #if defined(USE_YESCRYPT) - if (IS_CRYPT_METHOD("YESCRYPT") + if (IS_CRYPT_METHOD("YESCRYPT") && (-1 == str2sl(&yescrypt_cost, optarg))) { - bad_s = 1; - } + bad_s = 1; + } #endif /* USE_YESCRYPT */ - if (bad_s != 0) { + if (bad_s != 0) { fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg); diff --git a/src/chsh.c b/src/chsh.c index 0c2f7f6b8..0cfe26ee8 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -326,7 +326,7 @@ static void check_perms(const struct passwd *pw, const struct option_flags *flag */ if (!amroot && getdef_bool ("CHSH_AUTH")) { passwd_check(pw->pw_name, pw->pw_passwd); - } + } #else /* !USE_PAM */ pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */ diff --git a/src/groupdel.c b/src/groupdel.c index 2ef4fd8c6..5b4bb8d1f 100644 --- a/src/groupdel.c +++ b/src/groupdel.c @@ -97,7 +97,7 @@ static void fail_exit(int status) { #ifdef WITH_AUDIT audit_logger(AUDIT_GRP_MGMT, "delete-group", group_name, - AUDIT_NO_ID, SHADOW_AUDIT_FAILURE); + AUDIT_NO_ID, SHADOW_AUDIT_FAILURE); #endif exit (status); } diff --git a/src/newusers.c b/src/newusers.c index ab16a219c..8af65b7a2 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -139,7 +139,7 @@ static void usage (int status) #ifndef USE_PAM (void) fprintf (usageout, _(" -c, --crypt-method METHOD the crypt method (one of %s)\n"), - "NONE DES MD5" + "NONE DES MD5" #if defined(USE_SHA_CRYPT) " SHA256 SHA512" #endif @@ -635,7 +635,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) int c; #ifndef USE_PAM #if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT) - int bad_s; + int bad_s; #endif /* USE_SHA_CRYPT || USE_BCRYPT || USE_YESCRYPT */ #endif /* !USE_PAM */ static struct option long_options[] = { @@ -687,7 +687,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) #if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT) case 's': sflg = true; - bad_s = 0; + bad_s = 0; if (!crypt_method){ fprintf(stderr, @@ -698,22 +698,22 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) #if defined(USE_SHA_CRYPT) if ( ( (streq(crypt_method, "SHA256") || streq(crypt_method, "SHA512")) && (-1 == str2sl(&sha_rounds, optarg)))) { - bad_s = 1; - } + bad_s = 1; + } #endif /* USE_SHA_CRYPT */ #if defined(USE_BCRYPT) - if (( streq(crypt_method, "BCRYPT") + if ( ( streq(crypt_method, "BCRYPT") && (-1 == str2sl(&bcrypt_rounds, optarg)))) { - bad_s = 1; - } + bad_s = 1; + } #endif /* USE_BCRYPT */ #if defined(USE_YESCRYPT) - if (( streq(crypt_method, "YESCRYPT") + if ( ( streq(crypt_method, "YESCRYPT") && (-1 == str2sl(&yescrypt_cost, optarg)))) { - bad_s = 1; - } + bad_s = 1; + } #endif /* USE_YESCRYPT */ - if (bad_s != 0) { + if (bad_s != 0) { fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg); diff --git a/src/su.c b/src/su.c index e9b3f0f7b..583979c20 100644 --- a/src/su.c +++ b/src/su.c @@ -979,10 +979,10 @@ static void set_environment (struct passwd *pw) } #ifdef USE_PAM - /* we need to setup the environment *after* pam_open_session(), - * else the UID is changed before stuff like pam_xauth could - * run, and we cannot access /etc/shadow and co - */ + /* we need to setup the environment *after* pam_open_session(), + * else the UID is changed before stuff like pam_xauth could + * run, and we cannot access /etc/shadow and co + */ /* update environment with all pam set variables */ char **envcp = pam_getenvlist (pamh); if (NULL != envcp) { diff --git a/src/useradd.c b/src/useradd.c index c179ff4aa..e248cfbda 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -537,7 +537,7 @@ set_defaults(void) fprintf(stderr, _("%s: cannot create new defaults file: %s\n"), Prog, strerrno()); return -1; - } + } if (prefix[0]) { default_file = aprintf("%s/%s", prefix, USER_DEFAULTS_FILE); diff --git a/src/usermod.c b/src/usermod.c index 074b41fe2..2418514dd 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -1237,7 +1237,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) exit(E_BAD_ARG); } wflg = true; - break; + break; case 'W': if (prepend_range (optarg, &del_sub_gids) == 0) { fprintf (stderr,