Fix places where spaces were used instead of tabs.
No functional change.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
QChar_of(s) **endp_ = endp; \
T min_ = min; \
T max_ = max; \
- \
+ \
int status; \
- \
+ \
*n_ = _Generic((T){}, \
short: strtoi_, \
int: strtoi_, \
unsigned long: strtou_noneg, \
unsigned long long: strtou_noneg \
)(s, (char **) endp_, base, min_, max_, &status); \
- \
+ \
if (status != 0) \
errno = status; \
-!!status; \
}
/*
- * 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;
#endif
/*
* Default permissions and owner for newly created data file.
- */
+ */
mode_t st_mode;
uid_t st_uid;
gid_t st_gid;
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,
{ \
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)) { \
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); \
}
#define exit_if_null(p) \
({ \
__auto_type p_ = p; \
- \
+ \
exit_if_null_(p_); \
p_; \
})
/* 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;
}
/*
/* 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;
}
/*
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;
}
#define strnul(s) \
({ \
__auto_type s_ = s; \
- \
+ \
s_ + strlen(s_); \
})
#define strcaseprefix(s, prefix) \
({ \
const char *p_; \
- \
+ \
p_ = strcaseprefix_(s, prefix); \
- \
+ \
_Generic(s, \
const char *: p_, \
const void *: p_, \
#define strprefix(s, prefix) \
({ \
const char *p_; \
- \
+ \
p_ = strprefix_(s, prefix); \
- \
+ \
_Generic(s, \
const char *: p_, \
const void *: p_, \
#define stprcspn(s, reject) \
({ \
__auto_type s_ = (s); \
- \
+ \
s_ + strrcspn(s_, reject); \
})
#define stprspn(s, accept) \
({ \
__auto_type s_ = (s); \
- \
+ \
s_ + strrspn_(s_, accept); \
})
#define stpspn(s, accept) \
({ \
__auto_type s_ = s; \
- \
+ \
s_ + strspn(s_, accept); \
})
}
- /*
- * 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;
}
#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,
#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);
{
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'},
#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);
*/
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 */
{
#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);
}
#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
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[] = {
#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,
#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);
}
#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) {
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);
exit(E_BAD_ARG);
}
wflg = true;
- break;
+ break;
case 'W':
if (prepend_range (optarg, &del_sub_gids) == 0) {
fprintf (stderr,