lib/, src/: Fix formatting

Fix places where spaces were used instead of tabs.

No functional change.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
This commit is contained in:
Tobias Stoeckmann 2025-12-16 22:59:59 +01:00 committed by Alejandro Colomar
parent f787a0c7d5
commit 5369ad7566
23 changed files with 164 additions and 164 deletions

View File

@ -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; \

View File

@ -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;

View File

@ -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;

View File

@ -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); \
}

View File

@ -26,7 +26,7 @@
#define exit_if_null(p) \
({ \
__auto_type p_ = p; \
\
\
exit_if_null_(p_); \
p_; \
})

View File

@ -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;
}
/*

View File

@ -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;
}
/*

View File

@ -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;
}

View File

@ -18,7 +18,7 @@
#define strnul(s) \
({ \
__auto_type s_ = s; \
\
\
s_ + strlen(s_); \
})

View File

@ -19,9 +19,9 @@
#define strcaseprefix(s, prefix) \
({ \
const char *p_; \
\
\
p_ = strcaseprefix_(s, prefix); \
\
\
_Generic(s, \
const char *: p_, \
const void *: p_, \

View File

@ -19,9 +19,9 @@
#define strprefix(s, prefix) \
({ \
const char *p_; \
\
\
p_ = strprefix_(s, prefix); \
\
\
_Generic(s, \
const char *: p_, \
const void *: p_, \

View File

@ -17,7 +17,7 @@
#define stprcspn(s, reject) \
({ \
__auto_type s_ = (s); \
\
\
s_ + strrcspn(s_, reject); \
})

View File

@ -19,7 +19,7 @@
#define stprspn(s, accept) \
({ \
__auto_type s_ = (s); \
\
\
s_ + strrspn_(s_, accept); \
})

View File

@ -19,7 +19,7 @@
#define stpspn(s, accept) \
({ \
__auto_type s_ = s; \
\
\
s_ + strspn(s_, accept); \
})

View File

@ -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;
/*
* 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;
/*
* 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;
/* 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;
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;
}
/* 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;
}
/*
* 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;
/*
* 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;
}
range_owner_pwd = getpwnam(range->owner);
if (NULL == range_owner_pwd) {
continue;
}
if (owner_uid == range_owner_pwd->pw_uid) {
return range;
}
}
if (owner_uid == range_owner_pwd->pw_uid) {
return range;
}
}
return NULL;
}

View File

@ -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);

View File

@ -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);

View File

@ -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 */

View File

@ -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);
}

View File

@ -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);

View File

@ -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) {

View File

@ -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);

View File

@ -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,