]> granicus.if.org Git - sudo/commitdiff
Use %u to print uid/gid, not %lu and adjust casts to match.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 30 Nov 2010 20:22:07 +0000 (15:22 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 30 Nov 2010 20:22:07 +0000 (15:22 -0500)
--HG--
branch : 1.7

auth/kerb4.c
check.c
env.c
pwutil.c
sudo.c

index f3107a063536834d30ea0b6468352c8d403294ef..86bfc03d52dac23db14e15021209ec5a9fb33c28 100644 (file)
@@ -83,8 +83,8 @@ kerb4_verify(pw, pass, auth)
      * Set the ticket file to be in sudo sudo timedir so we don't
      * wipe out other (real) kerberos tickets.
      */
-    (void) snprintf(tkfile, sizeof(tkfile), "%s/tkt%lu",
-       _PATH_SUDO_TIMEDIR, (unsigned long) pw->pw_uid);
+    (void) snprintf(tkfile, sizeof(tkfile), "%s/tkt%u",
+       _PATH_SUDO_TIMEDIR, (unsigned int) pw->pw_uid);
     (void) krb_set_tkt_string(tkfile);
 
     /* Convert the password to a ticket given. */
diff --git a/check.c b/check.c
index e40e1238cf6388d64c27b9f15bcdcffd6d7a2a4e..b324c06bde8979651d3c7199c945660cba0ac8c5 100644 (file)
--- a/check.c
+++ b/check.c
@@ -453,9 +453,9 @@ timestamp_status(timestampdir, timestampfile, user, flags)
            log_error(NO_EXIT, "%s exists but is not a directory (0%o)",
                dirparent, (unsigned int) sb.st_mode);
        else if (sb.st_uid != timestamp_uid)
-           log_error(NO_EXIT, "%s owned by uid %lu, should be uid %lu",
-               dirparent, (unsigned long) sb.st_uid,
-               (unsigned long) timestamp_uid);
+           log_error(NO_EXIT, "%s owned by uid %u, should be uid %u",
+               dirparent, (unsigned int) sb.st_uid,
+               (unsigned int) timestamp_uid);
        else if ((sb.st_mode & 0000022))
            log_error(NO_EXIT,
                "%s writable by non-owner (0%o), should be mode 0700",
@@ -500,9 +500,9 @@ timestamp_status(timestampdir, timestampfile, user, flags)
                log_error(NO_EXIT, "%s exists but is not a directory (0%o)",
                    timestampdir, (unsigned int) sb.st_mode);
        } else if (sb.st_uid != timestamp_uid)
-           log_error(NO_EXIT, "%s owned by uid %lu, should be uid %lu",
-               timestampdir, (unsigned long) sb.st_uid,
-               (unsigned long) timestamp_uid);
+           log_error(NO_EXIT, "%s owned by uid %u, should be uid %u",
+               timestampdir, (unsigned int) sb.st_uid,
+               (unsigned int) timestamp_uid);
        else if ((sb.st_mode & 0000022))
            log_error(NO_EXIT,
                "%s writable by non-owner (0%o), should be mode 0700",
@@ -545,9 +545,9 @@ timestamp_status(timestampdir, timestampfile, user, flags)
                /* If bad uid or file mode, complain and kill the bogus file. */
                if (sb.st_uid != timestamp_uid) {
                    log_error(NO_EXIT,
-                       "%s owned by uid %lu, should be uid %lu",
-                       timestampfile, (unsigned long) sb.st_uid,
-                       (unsigned long) timestamp_uid);
+                       "%s owned by uid %u, should be uid %u",
+                       timestampfile, (unsigned int) sb.st_uid,
+                       (unsigned int) timestamp_uid);
                    (void) unlink(timestampfile);
                } else if ((sb.st_mode & 0000022)) {
                    log_error(NO_EXIT,
@@ -717,8 +717,8 @@ get_authpw()
            log_error(0, "unknown user: %s", def_runas_default);
     } else if (def_targetpw) {
        if (runas_pw->pw_name == NULL)
-           log_error(NO_MAIL|MSG_ONLY, "unknown uid: %lu",
-               (unsigned long) runas_pw->pw_uid);
+           log_error(NO_MAIL|MSG_ONLY, "unknown uid: %u",
+               (unsigned int) runas_pw->pw_uid);
        pw_addref(runas_pw);
        pw = runas_pw;
     } else {
diff --git a/env.c b/env.c
index 8bc5867433ec3b19e145cb18073faec88e1daedc..c26e0e0418e332a9060eec26e2f9cd84457a2c77 100644 (file)
--- a/env.c
+++ b/env.c
@@ -820,9 +820,9 @@ rebuild_env(noexec)
 
     /* Add the SUDO_USER, SUDO_UID, SUDO_GID environment variables. */
     sudo_setenv("SUDO_USER", user_name, TRUE);
-    snprintf(idbuf, sizeof(idbuf), "%lu", (unsigned long) user_uid);
+    snprintf(idbuf, sizeof(idbuf), "%u", (unsigned int) user_uid);
     sudo_setenv("SUDO_UID", idbuf, TRUE);
-    snprintf(idbuf, sizeof(idbuf), "%lu", (unsigned long) user_gid);
+    snprintf(idbuf, sizeof(idbuf), "%u", (unsigned int) user_gid);
     sudo_setenv("SUDO_GID", idbuf, TRUE);
 
     /* Free old environment. */
index d09e684a10e424761f7be6a86da3408b08124b35..26696fe70088f5268c629367c11dd1030047d50b 100644 (file)
--- a/pwutil.c
+++ b/pwutil.c
@@ -251,15 +251,16 @@ sudo_getpwuid(uid)
     if ((key.d.pw = getpwuid(uid)) != NULL) {
        item = make_pwitem(key.d.pw, NULL);
        if (rbinsert(pwcache_byuid, item) != NULL)
-           errorx(1, "unable to cache uid %lu (%s), already exists",
-               uid, item->d.pw->pw_name);
+           errorx(1, "unable to cache uid %u (%s), already exists",
+               (unsigned int) uid, item->d.pw->pw_name);
     } else {
        item = emalloc(sizeof(*item));
        item->refcnt = 1;
        item->k.uid = uid;
        item->d.pw = NULL;
        if (rbinsert(pwcache_byuid, item) != NULL)
-           errorx(1, "unable to cache uid %lu, already exists", uid);
+           errorx(1, "unable to cache uid %u, already exists",
+               (unsigned int) uid);
     }
 #ifdef HAVE_SETAUTHDB
     aix_restoreauthdb();
@@ -528,15 +529,16 @@ sudo_getgrgid(gid)
     if ((key.d.gr = getgrgid(gid)) != NULL) {
        item = make_gritem(key.d.gr, NULL);
        if (rbinsert(grcache_bygid, item) != NULL)
-           errorx(1, "unable to cache gid %lu (%s), already exists",
-               gid, key.d.gr->gr_name);
+           errorx(1, "unable to cache gid %u (%s), already exists",
+               (unsigned int) gid, key.d.gr->gr_name);
     } else {
        item = emalloc(sizeof(*item));
        item->refcnt = 1;
        item->k.gid = gid;
        item->d.gr = NULL;
        if (rbinsert(grcache_bygid, item) != NULL)
-           errorx(1, "unable to cache gid %lu, already exists, gid");
+           errorx(1, "unable to cache gid %u, already exists",
+               (unsigned int) gid);
     }
 done:
     item->refcnt++;
diff --git a/sudo.c b/sudo.c
index 9c3c944e95e01d12e5f26565b71d3f7c8770b30e..185e1ee032d668acbe1ce690b3c2bd8b0b523b9b 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -646,8 +646,8 @@ init_vars(envp)
        char pw_name[MAX_UID_T_LEN + 1];
 
        pw.pw_uid = getuid();
-       (void) snprintf(pw_name, sizeof(pw_name), "%lu",
-           (unsigned long) pw.pw_uid);
+       (void) snprintf(pw_name, sizeof(pw_name), "%u",
+           (unsigned int) pw.pw_uid);
        pw.pw_name = pw_name;
        sudo_user.pw = &pw;
 
@@ -1013,11 +1013,11 @@ open_sudoers(sudoers, doedit, keepopen)
            (unsigned int) (statbuf.st_mode & 07777),
            (unsigned int) SUDOERS_MODE);
     else if (statbuf.st_uid != SUDOERS_UID)
-       log_error(NO_EXIT, "%s is owned by uid %lu, should be %lu", sudoers,
-           (unsigned long) statbuf.st_uid, (unsigned long) SUDOERS_UID);
+       log_error(NO_EXIT, "%s is owned by uid %u, should be %u", sudoers,
+           (unsigned int) statbuf.st_uid, (unsigned int) SUDOERS_UID);
     else if (statbuf.st_gid != SUDOERS_GID)
-       log_error(NO_EXIT, "%s is owned by gid %lu, should be %lu", sudoers,
-           (unsigned long) statbuf.st_gid, (unsigned long) SUDOERS_GID);
+       log_error(NO_EXIT, "%s is owned by gid %u, should be %u", sudoers,
+           (unsigned int) statbuf.st_gid, (unsigned int) SUDOERS_GID);
     else if ((fp = fopen(sudoers, "r")) == NULL)
        log_error(USE_ERRNO|NO_EXIT, "can't open %s", sudoers);
     else {