Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions lib/age.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ int expire (const struct passwd *pw, /*@null@*/const struct spwd *sp)
* force them to change their password.
*/

status = isexpired (pw, sp);
status = isexpired(pw, sp);
switch (status) {
case 0:
return 0;
case 1:
(void) fputs (_("Your password has expired."), stdout);
(void) fputs(_("Your password has expired."), stdout);
break;
case 2:
(void) fputs (_("Your password is inactive."), stdout);
(void) fputs(_("Your password is inactive."), stdout);
break;
case 3:
(void) fputs (_("Your login has expired."), stdout);
(void) fputs(_("Your login has expired."), stdout);
break;
}

Expand All @@ -72,24 +72,24 @@ int expire (const struct passwd *pw, /*@null@*/const struct spwd *sp)
*/

if ((status > 1) || (sp->sp_max < sp->sp_min)) {
(void) puts (_(" Contact the system administrator."));
exit (EXIT_FAILURE);
(void) puts(_(" Contact the system administrator."));
exit(EXIT_FAILURE);
}
(void) puts (_(" Choose a new password."));
(void) fflush (stdout);
(void) puts(_(" Choose a new password."));
(void) fflush(stdout);

/*
* Close all the files so that unauthorized access won't
* occur. This needs to be done anyway because those files
* might become stale after "passwd" is executed.
*/

endspent ();
endpwent ();
endspent();
endpwent();
#ifdef SHADOWGRP
endsgent ();
endsgent();
#endif
endgrent ();
endgrent();

/*
* Execute the /bin/passwd command. The exit status will be
Expand All @@ -98,7 +98,7 @@ int expire (const struct passwd *pw, /*@null@*/const struct spwd *sp)
* change their password before being able to use the account.
*/

pid = fork ();
pid = fork();
if (0 == pid) {
int err;

Expand All @@ -108,30 +108,30 @@ int expire (const struct passwd *pw, /*@null@*/const struct spwd *sp)
* it from the command line while logged in.
*/
#if !defined(USE_PAM)
if (setup_uid_gid (pw, false) != 0)
if (setup_uid_gid(pw, false) != 0)
#else
if (setup_uid_gid (pw) != 0)
if (setup_uid_gid(pw) != 0)
#endif
{
_exit (126);
_exit(126);
}

(void) execl (PASSWD_PROGRAM, PASSWD_PROGRAM, pw->pw_name, (char *) NULL);
(void) execl(PASSWD_PROGRAM, PASSWD_PROGRAM, pw->pw_name, (char *) NULL);
err = errno;
perror ("Can't execute " PASSWD_PROGRAM);
_exit ((ENOENT == err) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
perror("Can't execute " PASSWD_PROGRAM);
_exit((ENOENT == err) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
} else if ((pid_t) -1 == pid) {
perror ("fork");
exit (EXIT_FAILURE);
perror("fork");
exit(EXIT_FAILURE);
}

while (((child = wait (&status)) != pid) && (child != (pid_t)-1));
while (((child = wait(&status)) != pid) && (child != (pid_t)-1));

if ((child == pid) && (0 == status)) {
return 1;
}

exit (EXIT_FAILURE);
exit(EXIT_FAILURE);
/*@notreached@*/}

/*
Expand Down Expand Up @@ -162,20 +162,20 @@ void agecheck (/*@null@*/const struct spwd *sp)
}

if (0 == sp->sp_lstchg) {
(void) puts (_("You must change your password."));
(void) puts(_("You must change your password."));
return;
}

remain = addsl(sp->sp_lstchg, sp->sp_max, -now);

if (remain <= sp->sp_warn) {
if (remain > 1) {
(void) printf (_("Your password will expire in %ld days.\n"),
(void) printf(_("Your password will expire in %ld days.\n"),
remain);
} else if (1 == remain) {
(void) puts (_("Your password will expire tomorrow."));
(void) puts(_("Your password will expire tomorrow."));
} else if (remain == 0) {
(void) puts (_("Your password will expire today."));
(void) puts(_("Your password will expire today."));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/alloc/calloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define calloc_T(n, T) calloc_T_(n, typeas(T))
#define calloc_T_(n, T) \
({ \
(T *){calloc(n, sizeof(T))}; \
(T *){calloc(n, sizeof (T))}; \
})


Expand Down
2 changes: 1 addition & 1 deletion lib/alloc/malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define malloc_T(n, T) malloc_T_(n, typeas(T))
#define malloc_T_(n, T) \
({ \
(T *){mallocarray(n, sizeof(T))}; \
(T *){mallocarray(n, sizeof (T))}; \
})


Expand Down
4 changes: 2 additions & 2 deletions lib/alloc/realloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#define realloc_T(p, n, T) realloc_T_(p, n, typeas(T))
#define realloc_T_(p, n, T) \
({ \
_Generic(p, T *: (void)0); \
(T *){reallocarray_(p, n, sizeof(T))}; \
_Generic (p, T *: (void)0); \
(T *){reallocarray_(p, n, sizeof (T))}; \
})

#define reallocarray_(p, n, size) reallocarray(p, (n) ?: 1, (size) ?: 1)
Expand Down
4 changes: 2 additions & 2 deletions lib/alloc/reallocf.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#define reallocf_T(p, n, T) reallocf_T_(p, n, typeas(T))
#define reallocf_T_(p, n, T) \
({ \
_Generic(p, T *: (void)0); \
(T *){reallocarrayf_(p, n, sizeof(T))}; \
_Generic (p, T *: (void)0); \
(T *){reallocarrayf_(p, n, sizeof (T))}; \
})

#define reallocarrayf_(p, n, size) reallocarrayf(p, (n) ?: 1, (size) ?: 1)
Expand Down
2 changes: 1 addition & 1 deletion lib/atoi/a2i.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
\
int status; \
\
*n_ = _Generic((T){0}, \
*n_ = _Generic ((T){0}, \
short: strtoi_, \
int: strtoi_, \
long: strtoi_, \
Expand Down
18 changes: 9 additions & 9 deletions lib/audit_help.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

int audit_fd;

void audit_help_open (void)
void audit_help_open(void)
{
audit_fd = audit_open ();
audit_fd = audit_open();
if (audit_fd < 0) {
/* You get these only when the kernel doesn't have
* audit compiled in. */
Expand All @@ -40,9 +40,9 @@ void audit_help_open (void)
|| (errno == EAFNOSUPPORT)) {
return;
}
(void) fputs (_("Cannot open audit interface - aborting.\n"),
(void) fputs(_("Cannot open audit interface - aborting.\n"),
log_get_logfd());
exit (EXIT_FAILURE);
exit(EXIT_FAILURE);
}
}

Expand All @@ -61,14 +61,14 @@ void audit_help_open (void)
* id - uid or gid that the operation is being performed on. This is used
* only when user is NULL.
*/
void audit_logger (int type, const char *op,
void audit_logger(int type, const char *op,
const char *name, unsigned int id,
shadow_audit_result result)
{
if (audit_fd < 0) {
return;
} else {
audit_log_acct_message (audit_fd, type, NULL, op, name, id,
audit_log_acct_message(audit_fd, type, NULL, op, name, id,
NULL, NULL, NULL, result);
}
}
Expand Down Expand Up @@ -102,7 +102,7 @@ audit_logger_with_group(int type, const char *op, const char *name,
if (audit_fd < 0)
return;

len = strnlen(grp, sizeof(enc_group)/2);
len = strnlen(grp, sizeof (enc_group)/2);
if (audit_value_needs_encoding(grp, len)) {
stprintf_a(buf, "%s %s=%s", op, grp_type,
audit_encode_value(enc_group, grp, len));
Expand All @@ -114,12 +114,12 @@ audit_logger_with_group(int type, const char *op, const char *name,
NULL, NULL, NULL, result);
}

void audit_logger_message (const char *message, shadow_audit_result result)
void audit_logger_message(const char *message, shadow_audit_result result)
{
if (audit_fd < 0) {
return;
} else {
audit_log_user_message (audit_fd,
audit_log_user_message(audit_fd,
AUDIT_USYS_CONFIG,
message,
NULL, /* hostname */
Expand Down
4 changes: 2 additions & 2 deletions lib/chkname.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ is_valid_group_name(const char *name)
* HP-UX 10 limits to 16 characters
*/
if ( (GROUP_NAME_MAX_LENGTH > 0)
&& (strlen (name) > GROUP_NAME_MAX_LENGTH))
&& (strlen(name) > GROUP_NAME_MAX_LENGTH))
{
errno = EOVERFLOW;
return false;
}

return is_valid_name (name);
return is_valid_name(name);
}
4 changes: 2 additions & 2 deletions lib/chkname.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <stdbool.h>


extern bool is_valid_user_name (const char *name);
extern bool is_valid_group_name (const char *name);
extern bool is_valid_user_name(const char *name);
extern bool is_valid_group_name(const char *name);

#endif
28 changes: 14 additions & 14 deletions lib/chowndir.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "string/strcmp/streq.h"


static int chown_tree_at (int at_fd,
static int chown_tree_at(int at_fd,
const char *path,
uid_t old_uid,
uid_t new_uid,
Expand All @@ -34,14 +34,14 @@ static int chown_tree_at (int at_fd,
struct stat dir_sb;
int dir_fd, rc = 0;

dir_fd = openat (at_fd, path, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
dir_fd = openat(at_fd, path, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
if (dir_fd < 0) {
return -1;
}

dir = fdopendir (dir_fd);
dir = fdopendir(dir_fd);
if (!dir) {
(void) close (dir_fd);
(void) close(dir_fd);
return -1;
}

Expand All @@ -51,7 +51,7 @@ static int chown_tree_at (int at_fd,
* recursively. If not, it is checked to see if an ownership
* shall be changed.
*/
while ((ent = readdir (dir))) {
while ((ent = readdir(dir))) {
uid_t tmpuid = (uid_t) -1;
gid_t tmpgid = (gid_t) -1;
struct stat ent_sb;
Expand All @@ -64,16 +64,16 @@ static int chown_tree_at (int at_fd,
continue;
}

rc = fstatat (dirfd(dir), ent->d_name, &ent_sb, AT_SYMLINK_NOFOLLOW);
rc = fstatat(dirfd(dir), ent->d_name, &ent_sb, AT_SYMLINK_NOFOLLOW);
if (rc < 0) {
break;
}

if (S_ISDIR (ent_sb.st_mode)) {
if (S_ISDIR(ent_sb.st_mode)) {
/*
* Do the entire subdirectory.
*/
rc = chown_tree_at (dirfd(dir), ent->d_name, old_uid, new_uid, old_gid, new_gid);
rc = chown_tree_at(dirfd(dir), ent->d_name, old_uid, new_uid, old_gid, new_gid);
if (0 != rc) {
break;
}
Expand All @@ -95,7 +95,7 @@ static int chown_tree_at (int at_fd,
tmpgid = new_gid;
}
if (((uid_t) -1 != tmpuid) || ((gid_t) -1 != tmpgid)) {
rc = fchownat (dirfd(dir), ent->d_name, tmpuid, tmpgid, AT_SYMLINK_NOFOLLOW);
rc = fchownat(dirfd(dir), ent->d_name, tmpuid, tmpgid, AT_SYMLINK_NOFOLLOW);
if (0 != rc) {
break;
}
Expand All @@ -105,7 +105,7 @@ static int chown_tree_at (int at_fd,
/*
* Now do the root of the tree
*/
if ((0 == rc) && (fstat (dirfd(dir), &dir_sb) == 0)) {
if ((0 == rc) && (fstat(dirfd(dir), &dir_sb) == 0)) {
uid_t tmpuid = (uid_t) -1;
gid_t tmpgid = (gid_t) -1;
if (((uid_t) -1 == old_uid) || (dir_sb.st_uid == old_uid)) {
Expand All @@ -115,13 +115,13 @@ static int chown_tree_at (int at_fd,
tmpgid = new_gid;
}
if (((uid_t) -1 != tmpuid) || ((gid_t) -1 != tmpgid)) {
rc = fchown (dirfd(dir), tmpuid, tmpgid);
rc = fchown(dirfd(dir), tmpuid, tmpgid);
}
} else {
rc = -1;
}

(void) closedir (dir);
(void) closedir(dir);

return rc;
}
Expand All @@ -139,11 +139,11 @@ static int chown_tree_at (int at_fd,
* new_uid and new_gid can be set to -1 to indicate that no owner or
* group-owner shall be changed.
*/
int chown_tree (const char *root,
int chown_tree(const char *root,
uid_t old_uid,
uid_t new_uid,
gid_t old_gid,
gid_t new_gid)
{
return chown_tree_at (AT_FDCWD, root, old_uid, new_uid, old_gid, new_gid);
return chown_tree_at(AT_FDCWD, root, old_uid, new_uid, old_gid, new_gid);
}
Loading
Loading