- Every non-const pointer converts automatically to void *.
- Every pointer converts automatically to void *.
- void * converts to any other pointer.
- const void * converts to any other const pointer.
- Integer variables convert to each other.
I changed the declaration of a few variables in order to allow removing
a cast.
However, I didn't attempt to edit casts inside comparisons, since they
are very delicate. I also kept casts in variadic functions, since they
are necessary, and in allocation functions, because I have other plans
for them.
I also changed a few casts to int that are better as ptrdiff_t.
This change has triggered some warnings about const correctness issues,
which have also been fixed in this patch (see for example src/login.c).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
while ((c = getc (stdin)) != EOF && (c != '\n') && (++i < maxlen))
{
bad = (!isalnum (c) && (c != '_') && (c != ' '));
- *(buf++) = (char) c;
+ *(buf++) = c;
}
*buf = '\0';
fd = open (file, O_WRONLY, 0600);
if (-1 == fd) {
if (log) {
- (void) fprintf (shadow_logfd, "%s: %s: %s\n",
- shadow_progname, file, strerror (errno));
+ (void) fprintf (shadow_logfd, "%s: %s: %s\n",
+ shadow_progname, file, strerror (errno));
}
return 0;
}
goto cleanup_ENOMEM;
}
- while (db->ops->fgets (buf, (int) buflen, db->fp) == buf) {
+ while (db->ops->fgets (buf, buflen, db->fp) == buf) {
while ( ((cp = strrchr (buf, '\n')) == NULL)
&& (feof (db->fp) == 0)) {
size_t len;
printf ("\t%s [%s]: ", prompt, buf);
(void) fflush (stdout);
- if (fgets (newf, (int) maxsize, stdin) != newf) {
+ if (fgets (newf, maxsize, stdin) != newf) {
return;
}
return 0;
}
- *gid = (gid_t)val;
+ *gid = val;
return 1;
}
return 0;
}
- *pid = (pid_t)val;
+ *pid = val;
return 1;
}
return 0;
}
- *uid = (uid_t)val;
+ *uid = val;
return 1;
}
#include "prototypes.h"
#include "defines.h"
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
}
d = def_find (item);
- return ((NULL == d)? (const char *) NULL : d->value);
+ return (NULL == d) ? NULL : d->value;
}
return dflt;
}
- return (int) val;
+ return val;
}
return dflt;
}
- return (unsigned int) val;
+ return val;
}
SYSLOG ((LOG_CRIT, "unknown configuration item `%s'", name));
out:
- return (struct itemdef *) NULL;
+ return NULL;
}
/*
/*
* Go through all of the lines in the file.
*/
- while (fgets (buf, (int) sizeof (buf), fp) != NULL) {
+ while (fgets (buf, sizeof (buf), fp) != NULL) {
/*
* Trim trailing whitespace.
*/
- for (i = (int) strlen (buf) - 1; i >= 0; --i) {
+ for (i = (ptrdiff_t) strlen (buf) - 1; i >= 0; --i) {
if (!isspace (buf[i])) {
break;
}
int gr_update (const struct group *gr)
{
- return commonio_update (&group_db, (const void *) gr);
+ return commonio_update (&group_db, gr);
}
int gr_remove (const char *name)
for (gr1 = group_db.head; NULL != gr1; gr1 = gr1->next) {
for (gr2 = gr1->next; NULL != gr2; gr2 = gr2->next) {
- struct group *g1 = (struct group *)gr1->eptr;
- struct group *g2 = (struct group *)gr2->eptr;
+ struct group *g1 = gr1->eptr;
+ struct group *g2 = gr2->eptr;
if (NULL != g1 &&
NULL != g2 &&
0 == strcmp (g1->gr_name, g2->gr_name) &&
return NULL;
}
- gptr1 = (struct group *)gr1->eptr;
- gptr2 = (struct group *)gr2->eptr;
+ gptr1 = gr1->eptr;
+ gptr2 = gr2->eptr;
if (NULL == gptr2 || NULL == gptr1) {
errno = EINVAL;
return NULL;
struct commonio_entry *gr;
for (gr = group_db.head; NULL != gr; gr = gr->next) {
- struct group *gptr = (struct group *)gr->eptr;
+ struct group *gptr = gr->eptr;
struct commonio_entry *new;
struct group *new_gptr;
unsigned int members = 0;
errno = ENOMEM;
return 0;
}
- new_gptr = (struct group *)new->eptr;
+ new_gptr = new->eptr;
new->line = NULL;
new->changed = true;
}
#ifdef USE_NIS
- while (fgetsx (buf, (int) buflen, fp) == buf)
+ while (fgetsx (buf, buflen, fp) == buf)
#else
- if (fgetsx (buf, (int) buflen, fp) == buf)
+ if (fgetsx (buf, buflen, fp) == buf)
#endif
{
while ( ((cp = strrchr (buf, '\n')) == NULL)
* Lines which begin with '#' are all ignored.
*/
- if (fgets (buf, (int) sizeof buf, ports) == 0) {
+ if (fgets (buf, sizeof buf, ports) == 0) {
errno = saveerr;
return 0;
}
int pw_update (const struct passwd *pw)
{
- return commonio_update (&passwd_db, (const void *) pw);
+ return commonio_update (&passwd_db, pw);
}
int pw_remove (const char *name)
int sgr_update (const struct sgrp *sg)
{
- return commonio_update (&gshadow_db, (const void *) sg);
+ return commonio_update (&gshadow_db, sg);
}
int sgr_remove (const char *name)
}
#ifdef USE_NIS
- while (fgets (buf, (int) sizeof buf, fp) != NULL)
+ while (fgets (buf, sizeof buf, fp) != NULL)
#else
- if (fgets (buf, (int) sizeof buf, fp) != NULL)
+ if (fgets (buf, sizeof buf, fp) != NULL)
#endif
{
cp = strchr (buf, '\n');
int spw_update (const struct spwd *sp)
{
- return commonio_update (&shadow_db, (const void *) sp);
+ return commonio_update (&shadow_db, sp);
}
int spw_remove (const char *name)
{
struct subordinate_range *range1, *range2;
- if ((*(struct commonio_entry **) p1)->eptr == NULL)
+
+ range1 = (*(struct commonio_entry **) p1)->eptr;
+ if (range1 == NULL)
return 1;
- if ((*(struct commonio_entry **) p2)->eptr == NULL)
- return -1;
- range1 = ((struct subordinate_range *) (*(struct commonio_entry **) p1)->eptr);
- range2 = ((struct subordinate_range *) (*(struct commonio_entry **) p2)->eptr);
+ range2 = (*(struct commonio_entry **) p2)->eptr;
+ if (range2 == NULL)
+ return -1;
if (range1->start < range2->start)
return -1;
shadow_progname, link);
return NULL;
}
- link[(size_t)ret] = '\0';
+ link[ret] = '\0';
rval = strdup (link);
if (NULL == rval) {
OUT_OF_MEMORY;
}
if (added) {
- ret = setgroups ((size_t)ngroups, grouplist);
+ ret = setgroups (ngroups, grouplist);
free (grouplist);
return ret;
}
void agecheck (/*@null@*/const struct spwd *sp)
{
- long now = (long) time(NULL) / SCALE;
+ long now = time(NULL) / SCALE;
long remain;
if (NULL == sp) {
return;
} else {
audit_log_acct_message (audit_fd, type, NULL, op, name, id,
- NULL, NULL, NULL, (int) result);
+ NULL, NULL, NULL, result);
}
}
NULL, /* hostname */
NULL, /* addr */
NULL, /* tty */
- (int) result);
+ result);
}
}
*/
if ( (fchown (STDIN_FILENO, info->pw_uid, gid) != 0)
- || (fchmod (STDIN_FILENO, (mode_t)getdef_num ("TTYPERM", 0600)) != 0)) {
+ || (fchmod (STDIN_FILENO, getdef_num ("TTYPERM", 0600)) != 0)) {
int err = errno;
FILE *shadow_logfd = log_get_logfd();
*/
void cleanup_report_add_group (void *group_name)
{
- const char *name = (const char *)group_name;
+ const char *name = group_name;
SYSLOG ((LOG_ERR, "failed to add group %s", name));
#ifdef WITH_AUDIT
*/
void cleanup_report_del_group (void *group_name)
{
- const char *name = (const char *)group_name;
+ const char *name = group_name;
SYSLOG ((LOG_ERR, "failed to remove group %s", name));
#ifdef WITH_AUDIT
*/
void cleanup_report_add_group_group (void *group_name)
{
- const char *name = (const char *)group_name;
+ const char *name = group_name;
SYSLOG ((LOG_ERR, "failed to add group %s to %s", name, gr_dbname ()));
#ifdef WITH_AUDIT
*/
void cleanup_report_add_group_gshadow (void *group_name)
{
- const char *name = (const char *)group_name;
+ const char *name = group_name;
SYSLOG ((LOG_ERR, "failed to add group %s to %s", name, sgr_dbname ()));
#ifdef WITH_AUDIT
*/
void cleanup_report_del_group_group (void *group_name)
{
- const char *name = (const char *)group_name;
+ const char *name = group_name;
SYSLOG ((LOG_ERR,
"failed to remove group %s from %s",
*/
void cleanup_report_del_group_gshadow (void *group_name)
{
- const char *name = (const char *)group_name;
+ const char *name = group_name;
SYSLOG ((LOG_ERR,
"failed to remove group %s from %s",
*/
void cleanup_report_add_user (void *user_name)
{
- const char *name = (const char *)user_name;
+ const char *name = user_name;
SYSLOG ((LOG_ERR, "failed to add user %s", name));
#ifdef WITH_AUDIT
*/
void cleanup_report_add_user_passwd (void *user_name)
{
- const char *name = (const char *)user_name;
+ const char *name = user_name;
SYSLOG ((LOG_ERR, "failed to add user %s to %s", name, pw_dbname ()));
#ifdef WITH_AUDIT
*/
void cleanup_report_add_user_shadow (void *user_name)
{
- const char *name = (const char *)user_name;
+ const char *name = user_name;
SYSLOG ((LOG_ERR, "failed to add user %s to %s", name, spw_dbname ()));
#ifdef WITH_AUDIT
* See if this tty is listed in the console file.
*/
- while (fgets (buf, (int) sizeof (buf), fp) != NULL) {
+ while (fgets (buf, sizeof (buf), fp) != NULL) {
/* Remove optional trailing '\n'. */
buf[strcspn (buf, "\n")] = '\0';
if (strcmp (buf, tty) == 0) {
written += res;
buf = (const unsigned char*)buf + res;
- count -= (size_t)res;
+ count -= res;
}
return written;
break;
}
- if (full_write (ofd, buf, (size_t)cnt) < 0) {
+ if (full_write (ofd, buf, cnt) < 0) {
(void) close (ofd);
(void) close (ifd);
return -1;
*/
if ( (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
- || (read (fd, (char *) fl, sizeof *fl) != (ssize_t) sizeof *fl)) {
+ || (read (fd, fl, sizeof *fl) != (ssize_t) sizeof *fl)) {
/* This is not necessarily a failure. The file is
* initially zero length.
*
*/
if ( (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
- || (write (fd, (char *) fl, sizeof *fl) != (ssize_t) sizeof *fl)
+ || (write (fd, fl, sizeof *fl) != (ssize_t) sizeof *fl)
|| (close (fd) != 0)) {
SYSLOG ((LOG_WARN,
"Can't write faillog entry for UID %lu in %s.",
*/
if ( (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
- || (read (fd, (char *) fl, sizeof *fl) != (ssize_t) sizeof *fl)) {
+ || (read (fd, fl, sizeof *fl) != (ssize_t) sizeof *fl)) {
(void) close (fd);
return 1;
}
fail.fail_cnt = 0;
if ( (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
- || (write (fd, (const void *) &fail, sizeof fail) != (ssize_t) sizeof fail)
+ || (write (fd, &fail, sizeof fail) != (ssize_t) sizeof fail)
|| (close (fd) != 0)) {
SYSLOG ((LOG_WARN,
"Can't reset faillog entry for UID %lu in %s.",
* Append the new failure record and close the log file.
*/
- if ( (write (fd, (const void *) failent, sizeof *failent) != (ssize_t) sizeof *failent)
+ if ( (write (fd, failent, sizeof *failent) != (ssize_t) sizeof *failent)
|| (close (fd) != 0)) {
SYSLOG ((LOG_WARN,
"Can't append failure of user %s to %s.",
*preferred_min = (gid_t) 1;
/* Get the minimum ID range from login.defs or default to 101 */
- *min_id = (gid_t) getdef_ulong ("SYS_GID_MIN", 101UL);
+ *min_id = getdef_ulong ("SYS_GID_MIN", 101UL);
/*
* If SYS_GID_MAX is unspecified, we should assume it to be one
* less than the GID_MIN (which is reserved for non-system accounts)
*/
- gid_def_max = (gid_t) getdef_ulong ("GID_MIN", 1000UL) - 1;
- *max_id = (gid_t) getdef_ulong ("SYS_GID_MAX",
- (unsigned long) gid_def_max);
+ gid_def_max = getdef_ulong ("GID_MIN", 1000UL) - 1;
+ *max_id = getdef_ulong ("SYS_GID_MAX", gid_def_max);
/* Check that the ranges make sense */
if (*max_id < *min_id) {
/* Non-system groups */
/* Get the values from login.defs or use reasonable defaults */
- *min_id = (gid_t) getdef_ulong ("GID_MIN", 1000UL);
- *max_id = (gid_t) getdef_ulong ("GID_MAX", 60000UL);
+ *min_id = getdef_ulong ("GID_MIN", 1000UL);
+ *max_id = getdef_ulong ("GID_MAX", 60000UL);
/*
* The preferred minimum should match the standard ID minimum
*preferred_min = (uid_t) 1;
/* Get the minimum ID range from login.defs or default to 101 */
- *min_id = (uid_t) getdef_ulong ("SYS_UID_MIN", 101UL);
+ *min_id = getdef_ulong ("SYS_UID_MIN", 101UL);
/*
* If SYS_UID_MAX is unspecified, we should assume it to be one
* less than the UID_MIN (which is reserved for non-system accounts)
*/
- uid_def_max = (uid_t) getdef_ulong ("UID_MIN", 1000UL) - 1;
- *max_id = (uid_t) getdef_ulong ("SYS_UID_MAX",
- (unsigned long) uid_def_max);
+ uid_def_max = getdef_ulong ("UID_MIN", 1000UL) - 1;
+ *max_id = getdef_ulong ("SYS_UID_MAX", uid_def_max);
/* Check that the ranges make sense */
if (*max_id < *min_id) {
/* Non-system users */
/* Get the values from login.defs or use reasonable defaults */
- *min_id = (uid_t) getdef_ulong ("UID_MIN", 1000UL);
- *max_id = (uid_t) getdef_ulong ("UID_MAX", 60000UL);
+ *min_id = getdef_ulong ("UID_MIN", 1000UL);
+ *max_id = getdef_ulong ("UID_MAX", 60000UL);
/*
* The preferred minimum should match the standard ID minimum
&& ('\0' == *endptr)
&& (ERANGE != errno)
&& (/*@+longintegral@*/gid == (gid_t)gid)/*@=longintegral@*/) {
- return xgetgrgid ((gid_t) gid);
+ return xgetgrgid (gid);
}
return xgetgrnam (grname);
}
fallback, epoch);
} else {
/* Valid */
- return (time_t)epoch;
+ return epoch;
}
return fallback;
if (NULL == fp) {
return false;
}
- for (found = false; !found && (fgets (buf, (int) sizeof buf, fp) == buf);) {
+ for (found = false; !found && (fgets (buf, sizeof buf, fp) == buf);) {
buf[strcspn (buf, "\n")] = '\0';
found = (strcmp (buf, pw->pw_shell) == 0) ||
(strcmp (buf, pw->pw_name) == 0);
{
long now;
- now = (long) time(NULL) / SCALE;
+ now = time(NULL) / SCALE;
if (NULL == sp) {
return 0;
return 0;
}
longlimit *= multiplier;
- limit = (rlim_t)longlimit;
+ limit = longlimit;
if (longlimit != limit)
{
/* FIXME: Again, silent error handling...
|| (prio != (int) prio)) {
return 0;
}
- if (setpriority (PRIO_PROCESS, 0, (int) prio) != 0) {
+ if (setpriority (PRIO_PROCESS, 0, prio) != 0) {
return LOGIN_ERROR_RLIMIT;
}
return 0;
return 0;
}
- (void) umask ((mode_t) mask);
+ (void) umask (mask);
return 0;
}
if ( (getlong (cp + 4, &inc) == 1)
&& (inc >= -20) && (inc <= 20)) {
errno = 0;
- if ( (nice ((int) inc) != -1)
+ if ( (nice (inc) != -1)
|| (0 != errno)) {
continue;
}
long int blocks;
if ( (getlong (cp + 7, &blocks) == 0)
|| (blocks != (int) blocks)
- || (set_filesize_limit ((int) blocks) != 0)) {
+ || (set_filesize_limit (blocks) != 0)) {
SYSLOG ((LOG_WARN,
"Can't set the ulimit for user %s",
info->pw_name));
"Can't set umask value for user %s",
info->pw_name));
} else {
- (void) umask ((mode_t) mask);
+ (void) umask (mask);
}
continue;
strncpy (newlog.ll_host, host, sizeof (newlog.ll_host) - 1);
#endif
if ( (lseek (fd, offset, SEEK_SET) != offset)
- || (write (fd, (const void *) &newlog, sizeof newlog) != (ssize_t) sizeof newlog)
+ || (write (fd, &newlog, sizeof newlog) != (ssize_t) sizeof newlog)
|| (close (fd) != 0)) {
SYSLOG ((LOG_WARN,
"Can't write lastlog entry for UID %lu in %s.",
*/
memzero (buf, sizeof buf);
- if (fgets (buf, (int) sizeof buf, stdin) != buf) {
+ if (fgets (buf, sizeof buf, stdin) != buf) {
exit (EXIT_FAILURE);
}
}
}
- maxlen = (size_t) getdef_num ("PASS_MAX_LEN", 8);
+ maxlen = getdef_num ("PASS_MAX_LEN", 8);
if ( (oldlen <= maxlen)
&& (newlen <= maxlen)) {
return NULL;
return PAM_CONV_ERR;
}
- responses = (struct pam_response *) calloc ((size_t) num_msg,
- sizeof (*responses));
+ responses = (struct pam_response *) calloc (num_msg, sizeof (*responses));
if (NULL == responses) {
return PAM_CONV_ERR;
}
&& ('\0' == *endptr)
&& (ERANGE != errno)
&& (gid == (gid_t)gid)) {
- return prefix_getgrgid ((gid_t) gid);
+ return prefix_getgrgid (gid);
}
g = prefix_getgrnam (grname);
return g ? __gr_dup(g) : NULL;
*/
sp.sp_min = 0;
sp.sp_max = (10000L * DAY) / SCALE;
- sp.sp_lstchg = (long) gettime () / SCALE;
+ sp.sp_lstchg = gettime () / SCALE;
if (0 == sp.sp_lstchg) {
/* Better disable aging than requiring a password
* change */
} else if (0 == strcmp (method, "BCRYPT")) {
BCRYPTMAGNUM(result);
salt_len = BCRYPT_SALT_SIZE;
- rounds = BCRYPT_get_salt_rounds ((int *) arg);
+ rounds = BCRYPT_get_salt_rounds (arg);
BCRYPT_salt_rounds_to_buf (result, rounds);
#endif /* USE_BCRYPT */
#ifdef USE_YESCRYPT
} else if (0 == strcmp (method, "YESCRYPT")) {
MAGNUM(result, 'y');
salt_len = YESCRYPT_SALT_SIZE;
- rounds = YESCRYPT_get_salt_cost ((int *) arg);
+ rounds = YESCRYPT_get_salt_cost (arg);
YESCRYPT_salt_cost_to_buf (result, rounds);
#endif /* USE_YESCRYPT */
#ifdef USE_SHA_CRYPT
} else if (0 == strcmp (method, "SHA256")) {
MAGNUM(result, '5');
salt_len = SHA_CRYPT_SALT_SIZE;
- rounds = SHA_get_salt_rounds ((int *) arg);
+ rounds = SHA_get_salt_rounds (arg);
SHA_salt_rounds_to_buf (result, rounds);
} else if (0 == strcmp (method, "SHA512")) {
MAGNUM(result, '6');
salt_len = SHA_CRYPT_SALT_SIZE;
- rounds = SHA_get_salt_rounds ((int *) arg);
+ rounds = SHA_get_salt_rounds (arg);
SHA_salt_rounds_to_buf (result, rounds);
#endif /* USE_SHA_CRYPT */
} else if (0 != strcmp (method, "DES")) {
perror (typefile);
return;
}
- while (fgets (buf, (int) sizeof buf, fp) == buf) {
+ while (fgets (buf, sizeof buf, fp) == buf) {
if (buf[0] == '#') {
continue;
}
fp = fopen (fname, "r");
if ( (NULL == fp)
- || (fgets (tzbuf, (int) sizeof (tzbuf), fp) == NULL)) {
+ || (fgets (tzbuf, sizeof (tzbuf), fp) == NULL)) {
def_tz = getdef_str ("ENV_TZ");
if ((NULL == def_tz) || ('/' == def_tz[0])) {
def_tz = "TZ=CST6CDT";
fd = open (filename, O_APPEND | O_WRONLY, 0);
if (fd >= 0) {
- write (fd, (const char *) ut, sizeof (*ut));
+ write (fd, ut, sizeof (*ut));
close (fd);
}
}
* Get a line and see what the first character is.
*/
/* TODO: use gettext */
- if (fgets (buf, (int) sizeof buf, stdin) == buf) {
+ if (fgets (buf, sizeof buf, stdin) == buf) {
return buf[0] == 'y' || buf[0] == 'Y';
}
int subid_get_uid_owners(uid_t uid, uid_t **owner)
{
- return get_subid_owner((unsigned long)uid, ID_TYPE_UID, owner);
+ return get_subid_owner(uid, ID_TYPE_UID, owner);
}
int subid_get_gid_owners(gid_t gid, uid_t **owner)
{
- return get_subid_owner((unsigned long)gid, ID_TYPE_GID, owner);
+ return get_subid_owner(gid, ID_TYPE_GID, owner);
}
static
#ifdef WITH_AUDIT
if (E_SUCCESS != code) {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
- "change age",
- user_name, (unsigned int) user_uid, 0);
+ "change age", user_name, user_uid, 0);
}
#endif
(void) puts (_("password must be changed"));
} else {
changed = lstchgdate * SCALE;
- print_date ((time_t) changed);
+ print_date (changed);
}
/*
(void) puts (_("never"));
} else {
expires = changed + maxdays * SCALE;
- print_date ((time_t) expires);
+ print_date (expires);
}
/*
(void) puts (_("never"));
} else {
expires = changed + (maxdays + inactdays) * SCALE;
- print_date ((time_t) expires);
+ print_date (expires);
}
/*
(void) puts (_("never"));
} else {
expires = expdate * SCALE;
- print_date ((time_t) expires);
+ print_date (expires);
}
/*
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
- "display aging info",
- user_name, (unsigned int) user_uid, 1);
+ "display aging info", user_name, user_uid, 1);
#endif
list_fields ();
fail_exit (E_SUCCESS);
else {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"change all aging information",
- user_name, (unsigned int) user_uid, 1);
+ user_name, user_uid, 1);
}
#endif
} else {
#ifdef WITH_AUDIT
if (Mflg) {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
- "change max age",
- user_name, (unsigned int) user_uid, 1);
+ "change max age", user_name, user_uid, 1);
}
if (mflg) {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
- "change min age",
- user_name, (unsigned int) user_uid, 1);
+ "change min age", user_name, user_uid, 1);
}
if (dflg) {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"change last change date",
- user_name, (unsigned int) user_uid, 1);
+ user_name, user_uid, 1);
}
if (Wflg) {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"change passwd warning",
- user_name, (unsigned int) user_uid, 1);
+ user_name, user_uid, 1);
}
if (Iflg) {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"change inactive days",
- user_name, (unsigned int) user_uid, 1);
+ user_name, user_uid, 1);
}
if (Eflg) {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"change passwd expiration",
- user_name, (unsigned int) user_uid, 1);
+ user_name, user_uid, 1);
}
#endif
}
* last change date is set in the age only if aging information is
* present.
*/
- while (fgets (buf, (int) sizeof buf, stdin) != NULL) {
+ while (fgets (buf, sizeof buf, stdin) != NULL) {
line++;
cp = strrchr (buf, '\n');
if (NULL != cp) {
if (feof (stdin) == 0) {
// Drop all remaining characters on this line.
- while (fgets (buf, (int) sizeof buf, stdin) != NULL) {
+ while (fgets (buf, sizeof buf, stdin) != NULL) {
cp = strchr (buf, '\n');
if (cp != NULL) {
break;
if (NULL != sp) {
newsp = *sp;
newsp.sp_pwdp = cp;
- newsp.sp_lstchg = (long) gettime () / SCALE;
+ newsp.sp_lstchg = gettime () / SCALE;
if (0 == newsp.sp_lstchg) {
/* Better disable aging than requiring a
* password change */
* entered for this user, which should be able to get the
* empty entry in this case.
*/
- if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
+ if (fread (&fl, sizeof (fl), 1, fail) != 1) {
fprintf (stderr,
_("%s: Failed to get the entry for UID %lu\n"),
Prog, (unsigned long int)pw->pw_uid);
static void print (void)
{
if (uflg && has_umin && has_umax && (umin==umax)) {
- print_one (getpwuid ((uid_t)umin), true);
+ print_one (getpwuid (umin), true);
} else {
/* We only print records for existing users.
* Loop based on the user database instead of reading the
* entered for this user, which should be able to get the
* empty entry in this case.
*/
- if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
+ if (fread (&fl, sizeof (fl), 1, fail) != 1) {
fprintf (stderr,
_("%s: Failed to get the entry for UID %lu\n"),
Prog, (unsigned long int)uid);
fl.fail_cnt = 0;
if ( (fseeko (fail, offset, SEEK_SET) == 0)
- && (fwrite ((char *) &fl, sizeof (fl), 1, fail) == 1)) {
+ && (fwrite (&fl, sizeof (fl), 1, fail) == 1)) {
(void) fflush (fail);
return false;
}
static void reset (void)
{
if (uflg && has_umin && has_umax && (umin==umax)) {
- if (reset_one ((uid_t)umin)) {
+ if (reset_one (umin)) {
errors = true;
}
} else {
uidmax--;
}
if (has_umax && (uid_t)umax < uidmax) {
- uidmax = (uid_t)umax;
+ uidmax = umax;
}
/* Reset all entries in the specified range.
/* Make sure we stay in the umin-umax range if specified */
if (has_umin) {
- uid = (uid_t)umin;
+ uid = umin;
}
while (uid <= uidmax) {
* entered for this user, which should be able to get the
* empty entry in this case.
*/
- if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
+ if (fread (&fl, sizeof (fl), 1, fail) != 1) {
fprintf (stderr,
_("%s: Failed to get the entry for UID %lu\n"),
Prog, (unsigned long int)uid);
fl.fail_max = max;
if ( (fseeko (fail, offset, SEEK_SET) == 0)
- && (fwrite ((char *) &fl, sizeof (fl), 1, fail) == 1)) {
+ && (fwrite (&fl, sizeof (fl), 1, fail) == 1)) {
(void) fflush (fail);
return false;
}
static void setmax (short max)
{
if (uflg && has_umin && has_umax && (umin==umax)) {
- if (setmax_one ((uid_t)umin, max)) {
+ if (setmax_one (umin, max)) {
errors = true;
}
} else {
/* Make sure we stay in the umin-umax range if specified */
if (has_umin) {
- uid = (uid_t)umin;
+ uid = umin;
}
if (has_umax) {
- uidmax = (uid_t)umax;
+ uidmax = umax;
}
while (uid <= uidmax) {
* entered for this user, which should be able to get the
* empty entry in this case.
*/
- if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
+ if (fread (&fl, sizeof (fl), 1, fail) != 1) {
fprintf (stderr,
_("%s: Failed to get the entry for UID %lu\n"),
Prog, (unsigned long int)uid);
fl.fail_locktime = locktime;
if ( (fseeko (fail, offset, SEEK_SET) == 0)
- && (fwrite ((char *) &fl, sizeof (fl), 1, fail) == 1)) {
+ && (fwrite (&fl, sizeof (fl), 1, fail) == 1)) {
(void) fflush (fail);
return false;
}
static void set_locktime (long locktime)
{
if (uflg && has_umin && has_umax && (umin==umax)) {
- if (set_locktime_one ((uid_t)umin, locktime)) {
+ if (set_locktime_one (umin, locktime)) {
errors = true;
}
} else {
/* Make sure we stay in the umin-umax range if specified */
if (has_umin) {
- uid = (uid_t)umin;
+ uid = umin;
}
if (has_umax) {
- uidmax = (uid_t)umax;
+ uidmax = umax;
}
while (uid <= uidmax) {
Prog, optarg);
exit (E_BAD_ARG);
}
- fail_max = (short) lmax;
+ fail_max = lmax;
mflg = true;
break;
}
/* local, no need for xgetpwnam */
pwent = getpwnam (optarg);
if (NULL != pwent) {
- umin = (unsigned long) pwent->pw_uid;
+ umin = pwent->pw_uid;
has_umin = true;
umax = umin;
has_umax = true;
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"adding group to /etc/group",
- group_name, (unsigned int) group_id,
- SHADOW_AUDIT_SUCCESS);
+ group_name, group_id, SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO, "group added to %s: name=%s, GID=%u",
gr_dbname (), group_name, (unsigned int) group_id));
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"adding group to /etc/gshadow",
- group_name, (unsigned int) group_id,
- SHADOW_AUDIT_SUCCESS);
+ group_name, group_id, SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO, "group added to %s: name=%s",
sgr_dbname (), group_name));
/* Report success at the system level */
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
- "",
- group_name, (unsigned int) group_id,
- SHADOW_AUDIT_SUCCESS);
+ "", group_name, group_id, SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO, "new group: name=%s, GID=%u",
group_name, (unsigned int) group_id));
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog,
"removing group from /etc/group",
- group_name, (unsigned int) group_id,
- SHADOW_AUDIT_SUCCESS);
+ group_name, group_id, SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO,
"group '%s' removed from %s",
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog,
"removing group from /etc/gshadow",
- group_name, (unsigned int) group_id,
- SHADOW_AUDIT_SUCCESS);
+ group_name, group_id, SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO,
"group '%s' removed from %s",
/* Report success at the system level */
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog,
- "",
- group_name, (unsigned int) group_id,
- SHADOW_AUDIT_SUCCESS);
+ "", group_name, group_id, SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO, "group '%s' removed\n", group_name));
del_cleanup (cleanup_report_del_group);
* entered for this user, which should be able to get the
* empty entry in this case.
*/
- if (fread ((char *) &ll, sizeof (ll), 1, lastlogfile) != 1) {
+ if (fread (&ll, sizeof (ll), 1, lastlogfile) != 1) {
fprintf (stderr,
_("%s: Failed to get the entry for UID %lu\n"),
Prog, (unsigned long int)pw->pw_uid);
}
if (uflg && has_umin && has_umax && (umin == umax)) {
- print_one (getpwuid ((uid_t)umin));
+ print_one (getpwuid (umin));
} else {
setpwent ();
while ( (pwent = getpwent ()) != NULL ) {
#ifdef WITH_AUDIT
audit_logger (AUDIT_ACCT_UNLOCK, Prog,
"clearing-lastlog",
- pw->pw_name, (unsigned int) pw->pw_uid, SHADOW_AUDIT_SUCCESS);
+ pw->pw_name, pw->pw_uid, SHADOW_AUDIT_SUCCESS);
#endif
}
#ifdef WITH_AUDIT
else {
audit_logger (AUDIT_ACCT_UNLOCK, Prog,
"refreshing-lastlog",
- pw->pw_name, (unsigned int) pw->pw_uid, SHADOW_AUDIT_SUCCESS);
+ pw->pw_name, pw->pw_uid, SHADOW_AUDIT_SUCCESS);
}
#endif
}
if (has_umin && has_umax && (umin == umax)) {
- update_one (getpwuid ((uid_t)umin));
+ update_one (getpwuid (umin));
} else {
setpwent ();
while ( (pwent = getpwent ()) != NULL ) {
/* local, no need for xgetpwnam */
pwent = getpwnam (optarg);
if (NULL != pwent) {
- umin = (unsigned long) pwent->pw_uid;
+ umin = pwent->pw_uid;
has_umin = true;
umax = umin;
has_umax = true;
#endif
/* leave these values unchanged if not specified in login.defs */
- erasechar = getdef_num ("ERASECHAR", (int) termio.c_cc[VERASE]);
- killchar = getdef_num ("KILLCHAR", (int) termio.c_cc[VKILL]);
- termio.c_cc[VERASE] = (cc_t) erasechar;
- termio.c_cc[VKILL] = (cc_t) killchar;
+ erasechar = getdef_num ("ERASECHAR", termio.c_cc[VERASE]);
+ killchar = getdef_num ("KILLCHAR", termio.c_cc[VKILL]);
+ termio.c_cc[VERASE] = erasechar;
+ termio.c_cc[VKILL] = killchar;
/* Make sure the values were valid.
* getdef_num cannot validate this.
*/
*/
static void get_pam_user (char **ptr_pam_user)
{
- int retcode;
- void *ptr_user;
+ int retcode;
+ const void *ptr_user;
assert (NULL != ptr_pam_user);
- retcode = pam_get_item (pamh, PAM_USER, (const void **)&ptr_user);
+ retcode = pam_get_item (pamh, PAM_USER, &ptr_user);
PAM_FAIL_CHECK;
free (*ptr_pam_user);
if (NULL != ptr_user) {
- *ptr_pam_user = xstrdup ((const char *)ptr_user);
+ *ptr_pam_user = xstrdup (ptr_user);
} else {
*ptr_pam_user = NULL;
}
}
if (strcmp (user_passwd, "") == 0) {
- char *prevent_no_auth = getdef_str("PREVENT_NO_AUTH");
+ const char *prevent_no_auth = getdef_str("PREVENT_NO_AUTH");
+
if (prevent_no_auth == NULL) {
prevent_no_auth = "superuser";
}
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
*/
#include <sys/types.h>
+#include <stddef.h>
#include <stdio.h>
#include <syslog.h>
#include <ctype.h>
if (NULL != fp) {
int lineno = 0; /* for diagnostics */
while ( !match
- && (fgets (line, (int) sizeof (line), fp) == line)) {
- int end;
+ && (fgets (line, sizeof (line), fp) == line)) {
+ ptrdiff_t end;
lineno++;
- end = (int) strlen (line) - 1;
+ end = strlen (line) - 1;
if (line[0] == '\0' || line[end] != '\n') {
SYSLOG ((LOG_ERR,
"%s: line %d: missing newline or line too long",
"authentication new-gid=%lu",
(unsigned long) grp->gr_gid);
audit_logger (AUDIT_GRP_AUTH, Prog,
- audit_buf, NULL,
- (unsigned int) getuid (), 0);
+ audit_buf, NULL, getuid (), 0);
#endif
SYSLOG ((LOG_INFO,
"Invalid password for group '%s' from '%s'",
"authentication new-gid=%lu",
(unsigned long) grp->gr_gid);
audit_logger (AUDIT_GRP_AUTH, Prog,
- audit_buf, NULL,
- (unsigned int) getuid (), 1);
+ audit_buf, NULL, getuid (), 1);
#endif
}
snprintf (audit_buf, sizeof(audit_buf),
"changing new-group=%s", groupname);
audit_logger (AUDIT_CHGRP_ID, Prog,
- audit_buf, NULL,
- (unsigned int) getuid (), 0);
+ audit_buf, NULL, getuid (), 0);
} else {
audit_logger (AUDIT_CHGRP_ID, Prog,
- "changing", NULL,
- (unsigned int) getuid (), 0);
+ "changing", NULL, getuid (), 0);
}
#endif
exit (EXIT_FAILURE);
snprintf (audit_buf, sizeof(audit_buf),
"changing new-group=%s", group);
audit_logger (AUDIT_CHGRP_ID, Prog,
- audit_buf, NULL,
- (unsigned int) getuid (), 0);
+ audit_buf, NULL, getuid (), 0);
} else {
audit_logger (AUDIT_CHGRP_ID, Prog,
- "changing", NULL,
- (unsigned int) getuid (), 0);
+ "changing", NULL, getuid (), 0);
}
#endif
exit (EXIT_FAILURE);
Prog);
#ifdef WITH_AUDIT
audit_logger (AUDIT_CHGRP_ID, Prog,
- "changing", NULL,
- (unsigned int) getuid (), 0);
+ "changing", NULL, getuid (), 0);
#endif
SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)",
(unsigned long) getuid ()));
snprintf (audit_buf, sizeof(audit_buf),
"changing new-group=%s", group);
audit_logger (AUDIT_CHGRP_ID, Prog,
- audit_buf, NULL,
- (unsigned int) getuid (), 0);
+ audit_buf, NULL, getuid (), 0);
} else {
audit_logger (AUDIT_CHGRP_ID, Prog,
- "changing", NULL,
- (unsigned int) getuid (), 0);
+ "changing", NULL, getuid (), 0);
}
#endif
exit (EXIT_FAILURE);
snprintf (audit_buf, sizeof(audit_buf),
"changing new-gid=%lu", (unsigned long) gid);
audit_logger (AUDIT_CHGRP_ID, Prog,
- audit_buf, NULL,
- (unsigned int) getuid (), 0);
+ audit_buf, NULL, getuid (), 0);
#endif
exit (EXIT_FAILURE);
}
snprintf (audit_buf, sizeof(audit_buf),
"changing new-gid=%lu", (unsigned long) gid);
audit_logger (AUDIT_CHGRP_ID, Prog,
- audit_buf, NULL,
- (unsigned int) getuid (), 0);
+ audit_buf, NULL, getuid (), 0);
#endif
exit (EXIT_FAILURE);
}
snprintf (audit_buf, sizeof(audit_buf),
"changing new-gid=%lu", (unsigned long) gid);
audit_logger (AUDIT_CHGRP_ID, Prog,
- audit_buf, NULL,
- (unsigned int) getuid (), 0);
+ audit_buf, NULL, getuid (), 0);
#endif
perror (SHELL);
exit ((errno == ENOENT) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
snprintf (audit_buf, sizeof(audit_buf), "changing new-gid=%lu",
(unsigned long) gid);
audit_logger (AUDIT_CHGRP_ID, Prog,
- audit_buf, NULL,
- (unsigned int) getuid (), 1);
+ audit_buf, NULL, getuid (), 1);
#endif
/*
* Exec the login shell and go away. We are trying to get back to
snprintf (audit_buf, sizeof(audit_buf),
"changing new-group=%s", group);
audit_logger (AUDIT_CHGRP_ID, Prog,
- audit_buf, NULL,
- (unsigned int) getuid (), 0);
+ audit_buf, NULL, getuid (), 0);
} else {
audit_logger (AUDIT_CHGRP_ID, Prog,
- "changing", NULL,
- (unsigned int) getuid (), 0);
+ "changing", NULL, getuid (), 0);
}
#endif
exit (EXIT_FAILURE);
/* Look in both the system database (getgrgid) and in the
* internal database (gr_locate_gid), which may contain
* uncommitted changes */
- if ( (getgrgid ((gid_t) grent.gr_gid) != NULL)
- || (gr_locate_gid ((gid_t) grent.gr_gid) != NULL)) {
+ if ( (getgrgid (grent.gr_gid) != NULL)
+ || (gr_locate_gid (grent.gr_gid) != NULL)) {
/* The user will use this ID for her
* primary group */
- *ngid = (gid_t) grent.gr_gid;
+ *ngid = grent.gr_gid;
return 0;
}
}
spent.sp_pwdp = cp;
}
- spent.sp_lstchg = (long) gettime () / SCALE;
+ spent.sp_lstchg = gettime () / SCALE;
if (0 == spent.sp_lstchg) {
/* Better disable aging than requiring a password
* change */
*/
spent.sp_pwdp = "!";
#endif
- spent.sp_lstchg = (long) gettime () / SCALE;
+ spent.sp_lstchg = gettime () / SCALE;
if (0 == spent.sp_lstchg) {
/* Better disable aging than requiring a password change */
spent.sp_lstchg = -1;
* over 100 is allocated. The pw_gid field will be updated with that
* value.
*/
- while (fgets (buf, (int) sizeof buf, stdin) != NULL) {
+ while (fgets (buf, sizeof buf, stdin) != NULL) {
line++;
cp = strrchr (buf, '\n');
if (NULL != cp) {
}
#ifndef USE_PAM
if (do_update_age) {
- nsp->sp_lstchg = (long) gettime () / SCALE;
+ nsp->sp_lstchg = gettime () / SCALE;
if (0 == nsp->sp_lstchg) {
/* Better disable aging than requiring a password
* change */
struct commonio_entry *pfe, *tpfe;
struct passwd *pwd;
const struct spwd *spw;
- uid_t min_sys_id = (uid_t) getdef_ulong ("SYS_UID_MIN", 101UL);
- uid_t max_sys_id = (uid_t) getdef_ulong ("SYS_UID_MAX", 999UL);
+ uid_t min_sys_id = getdef_ulong ("SYS_UID_MIN", 101UL);
+ uid_t max_sys_id = getdef_ulong ("SYS_UID_MAX", 999UL);
/*
* Loop through the entire password file.
sp.sp_inact = -1;
sp.sp_expire = -1;
sp.sp_flag = SHADOW_SP_FLAG_UNSET;
- sp.sp_lstchg = (long) gettime () / SCALE;
+ sp.sp_lstchg = gettime () / SCALE;
if (0 == sp.sp_lstchg) {
/* Better disable aging than
* requiring a password change
spent.sp_flag = SHADOW_SP_FLAG_UNSET;
}
spent.sp_pwdp = pw->pw_passwd;
- spent.sp_lstchg = (long) gettime () / SCALE;
+ spent.sp_lstchg = gettime () / SCALE;
if (0 == spent.sp_lstchg) {
/* Better disable aging than requiring a password
* change */
char *const envp[])
{
int err;
- (void) execve (shellname, (char **) args, envp);
+ (void) execve (shellname, args, envp);
err = errno;
if (access (shellname, R_OK|X_OK) == 0) {
}
if (strcmp (pw->pw_passwd, "") == 0) {
- char *prevent_no_auth = getdef_str("PREVENT_NO_AUTH");
+ const char *prevent_no_auth = getdef_str("PREVENT_NO_AUTH");
+
if (prevent_no_auth == NULL) {
prevent_no_auth = "superuser";
}
static /*@only@*/struct passwd * check_perms (void)
{
#ifdef USE_PAM
- const char *tmp_name;
+ const void *tmp_name;
int ret;
#endif /* !USE_PAM */
/*
#ifdef USE_PAM
check_perms_pam (pw);
/* PAM authentication can request a change of account */
- ret = pam_get_item(pamh, PAM_USER, (const void **) &tmp_name);
+ ret = pam_get_item(pamh, PAM_USER, &tmp_name);
if (ret != PAM_SUCCESS) {
SYSLOG((LOG_ERR, "pam_get_item: internal PAM error\n"));
(void) fprintf (stderr,
exit (1);
}
- ret = pam_set_item (pamh, PAM_TTY, (const void *) caller_tty);
+ ret = pam_set_item (pamh, PAM_TTY, caller_tty);
if (PAM_SUCCESS == ret) {
- ret = pam_set_item (pamh, PAM_RUSER, (const void *) caller_name);
+ ret = pam_set_item (pamh, PAM_RUSER, caller_name);
}
if (PAM_SUCCESS != ret) {
SYSLOG ((LOG_ERR, "pam_set_item: %s",
continue;
}
if (!(to_users = strtok (temp + posn, field))
- || !(from_users = strtok ((char *) NULL, field))
- || !(action = strtok ((char *) NULL, field))
- || strtok ((char *) NULL, field)) {
+ || !(from_users = strtok (NULL, field))
+ || !(action = strtok (NULL, field))
+ || strtok (NULL, field)) {
SYSLOG ((LOG_ERR,
"%s, line %d. Bad number of fields.\n",
SUAUTHFILE, lines));
* Read the file a line at a time. Only the lines that have relevant
* values are used, everything else can be ignored.
*/
- while (fgets (buf, (int) sizeof buf, fp) == buf) {
+ while (fgets (buf, sizeof buf, fp) == buf) {
cp = strrchr (buf, '\n');
if (NULL != cp) {
*cp = '\0';
goto skip;
}
- while (fgets (buf, (int) sizeof buf, ifp) == buf) {
+ while (fgets (buf, sizeof buf, ifp) == buf) {
cp = strrchr (buf, '\n');
if (NULL != cp) {
*cp = '\0';
&& ('\0' == *endptr)
&& (ERANGE != errno)
&& (gid == (gid_t)gid)) {
- grp = gr_locate_gid ((gid_t) gid);
+ grp = gr_locate_gid (gid);
}
else {
grp = gr_locate(grp_name);
memzero (spent, sizeof *spent);
spent->sp_namp = (char *) user_name;
spent->sp_pwdp = (char *) user_pass;
- spent->sp_lstchg = (long) gettime () / SCALE;
+ spent->sp_lstchg = gettime () / SCALE;
if (0 == spent->sp_lstchg) {
/* Better disable aging than requiring a password change */
spent->sp_lstchg = -1;
return;
}
- max_uid = (uid_t) getdef_ulong ("LASTLOG_UID_MAX", 0xFFFFFFFFUL);
+ max_uid = getdef_ulong ("LASTLOG_UID_MAX", 0xFFFFFFFFUL);
if (uid > max_uid) {
/* do not touch lastlog for large uids */
return;
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding shadow password",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_PW_UPDATE);
}
Prog, path);
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
- "adding home directory",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ "adding home directory",
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_HOMEDIR);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding home directory",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_SUCCESS);
+ user_name, user_id, SHADOW_AUDIT_SUCCESS);
#endif
#ifdef WITH_SELINUX
/* Reset SELinux to create files with default contexts */
uid_t uid_min ;
uid_t uid_max ;
if (rflg) {
- uid_max = (uid_t)getdef_ulong("SYS_UID_MAX",getdef_ulong("UID_MIN",1000UL)-1);
+ uid_max = getdef_ulong("SYS_UID_MAX",getdef_ulong("UID_MIN",1000UL)-1);
if (user_id > uid_max) {
fprintf(stderr, _("%s warning: %s's uid %d is greater than SYS_UID_MAX %d\n"), Prog, user_name, user_id, uid_max);
}
}else{
- uid_min = (uid_t)getdef_ulong("UID_MIN", 1000UL);
- uid_max = (uid_t)getdef_ulong("UID_MAX", 6000UL);
+ uid_min = getdef_ulong("UID_MIN", 1000UL);
+ uid_max = getdef_ulong("UID_MAX", 6000UL);
if (uid_min <= uid_max) {
if (user_id < uid_min || user_id >uid_max)
fprintf(stderr, _("%s warning: %s's uid %d outside of the UID_MIN %d and UID_MAX %d range.\n"), Prog, user_name, user_id, uid_min, uid_max);
process_flags (argc, argv);
#ifdef ENABLE_SUBIDS
- uid_min = (uid_t) getdef_ulong ("UID_MIN", 1000UL);
- uid_max = (uid_t) getdef_ulong ("UID_MAX", 60000UL);
+ uid_min = getdef_ulong ("UID_MIN", 1000UL);
+ uid_max = getdef_ulong ("UID_MAX", 60000UL);
subuid_count = getdef_ulong ("SUB_UID_COUNT", 65536);
subgid_count = getdef_ulong ("SUB_GID_COUNT", 65536);
is_sub_uid = subuid_count > 0 && sub_uid_file_present () &&
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding user",
- user_name, (unsigned int) user_id,
+ user_name, user_id,
SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_UID_IN_USE);
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding SELinux user mapping",
- user_name, (unsigned int) user_id, 0);
+ user_name, user_id, 0);
#endif /* WITH_AUDIT */
fail_exit (E_SE_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting user from group",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_SUCCESS);
+ user_name, user_id, SHADOW_AUDIT_SUCCESS);
#endif /* WITH_AUDIT */
SYSLOG ((LOG_INFO, "delete '%s' from group '%s'\n",
user_name, ngrp->gr_name));
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting user from shadow group",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_SUCCESS);
+ user_name, user_id, SHADOW_AUDIT_SUCCESS);
#endif /* WITH_AUDIT */
SYSLOG ((LOG_INFO, "delete '%s' from shadow group '%s'\n",
user_name, nsgrp->sg_name));
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting user",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
exit (code);
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"locking password file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_PW_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"opening password file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_PW_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"locking shadow password file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_PW_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"opening shadow password file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_PW_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"locking group file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"opening group file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"locking shadow group file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"opening shadow group file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"locking subordinate user file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_SUB_UID_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"opening subordinate user file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_SUB_UID_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"locking subordinate group file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_SUB_GID_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"opening subordinate group file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_SUB_GID_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting user entries",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_SUCCESS);
+ user_name, user_id, SHADOW_AUDIT_SUCCESS);
#endif /* WITH_AUDIT */
SYSLOG ((LOG_INFO, "delete user '%s'\n", user_name));
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
free(mailfile);
return -1;
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
errors = 1;
/* continue */
{
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_SUCCESS);
+ user_name, user_id, SHADOW_AUDIT_SUCCESS);
}
#endif /* WITH_AUDIT */
free(mailfile);
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
free(mailfile);
return 1;
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
errors = 1;
/* continue */
{
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_SUCCESS);
+ user_name, user_id, SHADOW_AUDIT_SUCCESS);
}
#endif /* WITH_AUDIT */
free(mailfile);
{
audit_logger (AUDIT_DEL_USER, Prog,
"deleting home directory",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_SUCCESS);
+ user_name, user_id, SHADOW_AUDIT_SUCCESS);
}
#endif /* WITH_AUDIT */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"removing SELinux user mapping",
- user_name, (unsigned int) user_id,
- SHADOW_AUDIT_FAILURE);
+ user_name, user_id, SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_SE_UPDATE);
}
static int get_groups (char *list)
{
char *cp;
- const struct group *grp;
+ struct group *grp;
int errors = 0;
int ngroups = 0;
fprintf (stderr,
_("%s: group '%s' is a NIS group.\n"),
Prog, grp->gr_name);
- gr_free ((struct group *)grp);
+ gr_free (grp);
continue;
}
#endif
fprintf (stderr,
_("%s: too many groups specified (max %d).\n"),
Prog, ngroups);
- gr_free ((struct group *)grp);
+ gr_free (grp);
break;
}
* Add the group name to the user's list of groups.
*/
user_groups[ngroups++] = xstrdup (grp->gr_name);
- gr_free ((struct group *)grp);
+ gr_free (grp);
} while (NULL != list);
user_groups[ngroups] = NULL;
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
- "updating passwd",
- user_newname, (unsigned int) user_newid, 0);
+ "updating passwd", user_newname, user_newid, 0);
#endif
SYSLOG ((LOG_INFO, "lock user '%s' password", user_newname));
strcpy (buf, "!");
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
- "updating password",
- user_newname, (unsigned int) user_newid, 0);
+ "updating password", user_newname, user_newid, 0);
#endif
SYSLOG ((LOG_INFO, "unlock user '%s' password", user_newname));
s = pw_pass;
} else if (pflg) {
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
- "changing password",
- user_newname, (unsigned int) user_newid, 1);
+ "changing password", user_newname, user_newid, 1);
#endif
SYSLOG ((LOG_INFO, "change user '%s' password", user_newname));
pw_pass = xstrdup (user_pass);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
- "changing name",
- user_newname, (unsigned int) user_newid, 1);
+ "changing name", user_newname, user_newid, 1);
#endif
SYSLOG ((LOG_INFO,
"change user name '%s' to '%s'",
if (uflg) {
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
- "changing uid",
- user_newname, (unsigned int) user_newid, 1);
+ "changing uid", user_newname, user_newid, 1);
#endif
SYSLOG ((LOG_INFO,
"change user '%s' UID from '%d' to '%d'",
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"changing primary group",
- user_newname, (unsigned int) user_newid, 1);
+ user_newname, user_newid, 1);
#endif
SYSLOG ((LOG_INFO,
"change user '%s' GID from '%d' to '%d'",
if (cflg) {
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
- "changing comment",
- user_newname, (unsigned int) user_newid, 1);
+ "changing comment", user_newname, user_newid, 1);
#endif
pwent->pw_gecos = user_newcomment;
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"changing home directory",
- user_newname, (unsigned int) user_newid, 1);
+ user_newname, user_newid, 1);
#endif
SYSLOG ((LOG_INFO,
"change user '%s' home from '%s' to '%s'",
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"changing user shell",
- user_newname, (unsigned int) user_newid, 1);
+ user_newname, user_newid, 1);
#endif
SYSLOG ((LOG_INFO,
"change user '%s' shell from '%s' to '%s'",
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"changing inactive days",
- user_newname, (unsigned int) user_newid, 1);
+ user_newname, user_newid, 1);
#endif
SYSLOG ((LOG_INFO,
"change user '%s' inactive from '%ld' to '%ld'",
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"changing expiration date",
- user_newname, (unsigned int) user_newid, 1);
+ user_newname, user_newid, 1);
#endif
SYSLOG ((LOG_INFO,
"change user '%s' expiration from '%s' to '%s'",
spent->sp_pwdp = new_pw_passwd (spent->sp_pwdp);
if (pflg) {
- spent->sp_lstchg = (long) gettime () / SCALE;
+ spent->sp_lstchg = gettime () / SCALE;
if (0 == spent->sp_lstchg) {
/* Better disable aging than requiring a password
* change. */
spent.sp_pwdp = xstrdup (pwent.pw_passwd);
pwent.pw_passwd = xstrdup (SHADOW_PASSWD_STRING);
- spent.sp_lstchg = (long) gettime () / SCALE;
+ spent.sp_lstchg = gettime () / SCALE;
if (0 == spent.sp_lstchg) {
/* Better disable aging than
* requiring a password change */
if (uflg || gflg) {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"changing home directory owner",
- user_newname, (unsigned int) user_newid, 1);
+ user_newname, user_newid, 1);
}
#endif
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"moving home directory",
- user_newname, (unsigned int) user_newid,
- 1);
+ user_newname, user_newid, 1);
#endif
return;
} else {
Prog,
"moving home directory",
user_newname,
- (unsigned int) user_newid,
+ user_newid,
1);
#endif
return;
return;
}
- max_uid = (uid_t) getdef_ulong ("LASTLOG_UID_MAX", 0xFFFFFFFFUL);
+ max_uid = getdef_ulong ("LASTLOG_UID_MAX", 0xFFFFFFFFUL);
if (user_newid > max_uid) {
/* do not touch lastlog for large uids */
return;
}
if ( (lseek (fd, off_uid, SEEK_SET) == off_uid)
- && (read (fd, (char *) &fl, sizeof fl) == (ssize_t) sizeof fl)) {
+ && (read (fd, &fl, sizeof fl) == (ssize_t) sizeof fl)) {
/* Copy the old entry to its new location */
if ( (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
|| (write (fd, &fl, sizeof fl) != (ssize_t) sizeof fl)
else {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"changing mail file owner",
- user_newname, (unsigned int) user_newid, 1);
+ user_newname, user_newid, 1);
}
#endif
}
else {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"changing mail file name",
- user_newname, (unsigned int) user_newid, 1);
+ user_newname, user_newid, 1);
}
#endif
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"modifying User mapping ",
- user_name, (unsigned int) user_id,
+ user_name, user_id,
SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_SE_UPDATE);
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"removing SELinux user mapping",
- user_name, (unsigned int) user_id,
+ user_name, user_id,
SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
fail_exit (E_SE_UPDATE);
if (uflg || gflg) {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"changing home directory owner",
- user_newname, (unsigned int) user_newid, 1);
+ user_newname, user_newid, 1);
}
#endif
if (chown_tree (dflg ? prefix_user_newhome : prefix_user_home,