openssh-2.9.9p2 assumes pid_t, uid_t, etc. are not 'long'
Paul Eggert
eggert at twinsun.com
Sat Sep 29 04:47:04 EST 2001
openssh-2.9.9p2 assumes that pid_t, uid_t, gid_t, and mode_t are no
wider than int. GCC complains about this assumption on 32-bit Solaris
8 sparc, where these types are 'long', not 'int'. This isn't an
actual problem at runtime on this host, as long and int are the same
width, but it is a problem on other hosts where pid_t is wider than
int. E.g., I've heard that 64-bit AIX has 64-bit pid_t in some
compilation environments.
Here is a patch.
2001-09-28 Paul Eggert <eggert at twinsun.com>
* authfile.c (key_perm_ok):
Work even if system integer types are 'long', not 'int'.
* entropy.c (prng_check_seedfile, prng_write_seedfile,
prng_read_seedfile): Likewise.
* serverloop.c (server_loop, server_loop2): Likewise.
* session.c (session_dump, session_by_pid,
session_exit_message, session_close_by_pid,
session_have_children, session_close_by_channel): Likewise.
* ssh-agent.c, sshd.c (main): Likewise.
* sshpty.c (pty_setowner): Likewise.
* uidswap.c: (temporarily_use_uid): Likewise.
===================================================================
RCS file: authfile.c,v
retrieving revision 2.9.9.2
retrieving revision 2.9.9.2.0.1
diff -pu -r2.9.9.2 -r2.9.9.2.0.1
--- authfile.c 2001/09/23 13:53:22 2.9.9.2
+++ authfile.c 2001/09/28 18:37:50 2.9.9.2.0.1
@@ -501,7 +501,7 @@ key_perm_ok(int fd, const char *filename
error("@ WARNING: UNPROTECTED PRIVATE KEY FILE! @");
error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
error("Permissions 0%3.3o for '%s' are too open.",
- st.st_mode & 0777, filename);
+ (int) (st.st_mode & 0777), filename);
error("It is recommended that your private key files are NOT accessible by others.");
error("This private key will be ignored.");
return 0;
===================================================================
RCS file: entropy.c,v
retrieving revision 2.9
retrieving revision 2.9.9.2.0.1
diff -pu -r2.9 -r2.9.9.2.0.1
--- entropy.c 2001/08/06 06:51:49 2.9
+++ entropy.c 2001/09/28 18:37:50 2.9.9.2.0.1
@@ -596,8 +596,8 @@ prng_check_seedfile(char *filename) {
/* mode 0600, owned by root or the current user? */
if (((st.st_mode & 0177) != 0) || !(st.st_uid == original_uid)) {
- debug("WARNING: PRNG seedfile %.100s must be mode 0600, owned by uid %d",
- filename, getuid());
+ debug("WARNING: PRNG seedfile %.100s must be mode 0600, owned by uid %ld",
+ filename, (long)getuid());
return(0);
}
@@ -621,8 +621,8 @@ prng_write_seedfile(void) {
pw = getpwuid(original_uid);
if (pw == NULL)
- fatal("Couldn't get password entry for current user (%i): %s",
- original_uid, strerror(errno));
+ fatal("Couldn't get password entry for current user (%ld): %s",
+ (long)original_uid, strerror(errno));
/* Try to ensure that the parent directory is there */
snprintf(filename, sizeof(filename), "%.512s/%s", pw->pw_dir,
@@ -660,8 +660,8 @@ prng_read_seedfile(void) {
pw = getpwuid(original_uid);
if (pw == NULL)
- fatal("Couldn't get password entry for current user (%i): %s",
- original_uid, strerror(errno));
+ fatal("Couldn't get password entry for current user (%ld): %s",
+ (long)original_uid, strerror(errno));
snprintf(filename, sizeof(filename), "%.512s/%s", pw->pw_dir,
SSH_PRNG_SEED_FILE);
===================================================================
RCS file: serverloop.c,v
retrieving revision 2.9.9.2
retrieving revision 2.9.9.2.0.1
diff -pu -r2.9.9.2 -r2.9.9.2.0.1
--- serverloop.c 2001/09/18 05:53:13 2.9.9.2
+++ serverloop.c 2001/09/28 18:37:50 2.9.9.2.0.1
@@ -631,8 +631,8 @@ server_loop(pid_t pid, int fdin_arg, int
if (wait_pid == -1)
packet_disconnect("wait: %.100s", strerror(errno));
else if (wait_pid != pid)
- error("Strange, wait returned pid %d, expected %d",
- wait_pid, pid);
+ error("Strange, wait returned pid %ld, expected %ld",
+ (long)wait_pid, (long)pid);
/* Check if it exited normally. */
if (WIFEXITED(wait_status)) {
@@ -730,7 +730,7 @@ server_loop2(Authctxt *authctxt)
if (pid > 0)
session_close_by_pid(pid, status);
else {
- error("waitpid returned %d: %s", pid, strerror(errno));
+ error("waitpid returned %ld: %s", (long)pid, strerror(errno));
break;
}
}
===================================================================
RCS file: session.c,v
retrieving revision 2.9.9.2.0.1
retrieving revision 2.9.9.2.0.2
diff -pu -r2.9.9.2.0.1 -r2.9.9.2.0.2
--- session.c 2001/09/28 18:17:11 2.9.9.2.0.1
+++ session.c 2001/09/28 18:37:50 2.9.9.2.0.2
@@ -1539,12 +1539,12 @@ session_dump(void)
int i;
for(i = 0; i < MAX_SESSIONS; i++) {
Session *s = &sessions[i];
- debug("dump: used %d session %d %p channel %d pid %d",
+ debug("dump: used %d session %d %p channel %d pid %ld",
s->used,
s->self,
s,
s->chanid,
- s->pid);
+ (long)s->pid);
}
}
@@ -1586,13 +1586,13 @@ static Session *
session_by_pid(pid_t pid)
{
int i;
- debug("session_by_pid: pid %d", pid);
+ debug("session_by_pid: pid %ld", (long)pid);
for(i = 0; i < MAX_SESSIONS; i++) {
Session *s = &sessions[i];
if (s->used && s->pid == pid)
return s;
}
- error("session_by_pid: unknown pid %d", pid);
+ error("session_by_pid: unknown pid %ld", (long)pid);
session_dump();
return NULL;
}
@@ -1874,8 +1874,8 @@ session_exit_message(Session *s, int sta
if (c == NULL)
fatal("session_exit_message: session %d: no channel %d",
s->self, s->chanid);
- debug("session_exit_message: session %d channel %d pid %d",
- s->self, s->chanid, s->pid);
+ debug("session_exit_message: session %d channel %d pid %ld",
+ s->self, s->chanid, (long)s->pid);
if (WIFEXITED(status)) {
channel_request_start(s->chanid,
@@ -1916,7 +1916,7 @@ session_exit_message(Session *s, int sta
static void
session_close(Session *s)
{
- debug("session_close: session %d pid %d", s->self, s->pid);
+ debug("session_close: session %d pid %ld", s->self, (long)s->pid);
if (s->ttyfd != -1) {
fatal_remove_cleanup(session_pty_cleanup, (void *)s);
session_pty_cleanup(s);
@@ -1938,7 +1938,7 @@ session_close_by_pid(pid_t pid, int stat
{
Session *s = session_by_pid(pid);
if (s == NULL) {
- debug("session_close_by_pid: no session for pid %d", pid);
+ debug("session_close_by_pid: no session for pid %ld", (long)pid);
return;
}
if (s->chanid != -1)
@@ -1954,7 +1954,7 @@ session_have_children(void)
for(i = 0; i < MAX_SESSIONS; i++) {
Session *s = &sessions[i];
if (s->used && s->pid != -1) {
- debug("session_have_children: id %d pid %d", i, s->pid);
+ debug("session_have_children: id %d pid %ld", i, (long)s->pid);
return 1;
}
}
@@ -1978,15 +1978,15 @@ session_close_by_channel(int id, void *a
channel_cancel_cleanup(s->chanid);
s->chanid = -1;
- debug("session_close_by_channel: channel %d kill %d", id, s->pid);
+ debug("session_close_by_channel: channel %d kill %ld", id, (long)s->pid);
if (s->pid == 0) {
/* close session immediately */
session_close(s);
} else {
/* notify child, delay session cleanup */
if (kill(s->pid, (s->ttyfd == -1) ? SIGTERM : SIGHUP) < 0)
- error("session_close_by_channel: kill %d: %s",
- s->pid, strerror(errno));
+ error("session_close_by_channel: kill %ld: %s",
+ (long)s->pid, strerror(errno));
}
}
===================================================================
RCS file: ssh-agent.c,v
retrieving revision 2.9.9.2
retrieving revision 2.9.9.2.0.1
diff -pu -r2.9.9.2 -r2.9.9.2.0.1
--- ssh-agent.c 2001/08/06 22:06:35 2.9.9.2
+++ ssh-agent.c 2001/09/28 18:37:50 2.9.9.2.0.1
@@ -912,7 +912,7 @@ main(int ac, char **av)
format = c_flag ? "unsetenv %s;\n" : "unset %s;\n";
printf(format, SSH_AUTHSOCKET_ENV_NAME);
printf(format, SSH_AGENTPID_ENV_NAME);
- printf("echo Agent pid %d killed;\n", pid);
+ printf("echo Agent pid %ld killed;\n", (long)pid);
exit(0);
}
parent_pid = getpid();
@@ -965,7 +965,7 @@ main(int ac, char **av)
format = c_flag ? "setenv %s %s;\n" : "%s=%s; export %s;\n";
printf(format, SSH_AUTHSOCKET_ENV_NAME, socket_name,
SSH_AUTHSOCKET_ENV_NAME);
- printf("echo Agent pid %d;\n", parent_pid);
+ printf("echo Agent pid %ld;\n", (long)parent_pid);
goto skip;
}
pid = fork();
@@ -982,7 +982,7 @@ main(int ac, char **av)
SSH_AUTHSOCKET_ENV_NAME);
printf(format, SSH_AGENTPID_ENV_NAME, pidstrbuf,
SSH_AGENTPID_ENV_NAME);
- printf("echo Agent pid %d;\n", pid);
+ printf("echo Agent pid %ld;\n", (long)pid);
exit(0);
}
if (setenv(SSH_AUTHSOCKET_ENV_NAME, socket_name, 1) == -1 ||
===================================================================
RCS file: sshd.c,v
retrieving revision 2.9.9.2
retrieving revision 2.9.9.2.0.1
diff -pu -r2.9.9.2 -r2.9.9.2.0.1
--- sshd.c 2001/09/18 04:03:04 2.9.9.2
+++ sshd.c 2001/09/28 18:37:50 2.9.9.2.0.1
@@ -1068,7 +1068,7 @@ main(int ac, char **av)
if (pid < 0)
error("fork: %.100s", strerror(errno));
else
- debug("Forked child %d.", pid);
+ debug("Forked child %ld.", (long)pid);
close(startup_p[1]);
===================================================================
RCS file: sshpty.c,v
retrieving revision 2.9.9.2
retrieving revision 2.9.9.2.0.1
diff -pu -r2.9.9.2 -r2.9.9.2.0.1
--- sshpty.c 2001/08/14 20:41:35 2.9.9.2
+++ sshpty.c 2001/09/28 18:37:50 2.9.9.2.0.1
@@ -381,12 +381,12 @@ pty_setowner(struct passwd *pw, const ch
if (chown(ttyname, pw->pw_uid, gid) < 0) {
if (errno == EROFS &&
(st.st_uid == pw->pw_uid || st.st_uid == 0))
- error("chown(%.100s, %d, %d) failed: %.100s",
- ttyname, pw->pw_uid, gid,
+ error("chown(%.100s, %ld, %ld) failed: %.100s",
+ ttyname, (long)pw->pw_uid, (long)gid,
strerror(errno));
else
- fatal("chown(%.100s, %d, %d) failed: %.100s",
- ttyname, pw->pw_uid, gid,
+ fatal("chown(%.100s, %ld, %ld) failed: %.100s",
+ ttyname, (long)pw->pw_uid, (long)gid,
strerror(errno));
}
}
@@ -395,11 +395,11 @@ pty_setowner(struct passwd *pw, const ch
if (chmod(ttyname, mode) < 0) {
if (errno == EROFS &&
(st.st_mode & (S_IRGRP | S_IROTH)) == 0)
- error("chmod(%.100s, 0%o) failed: %.100s",
- ttyname, mode, strerror(errno));
+ error("chmod(%.100s, 0%lo) failed: %.100s",
+ ttyname, (long)mode, strerror(errno));
else
- fatal("chmod(%.100s, 0%o) failed: %.100s",
- ttyname, mode, strerror(errno));
+ fatal("chmod(%.100s, 0%lo) failed: %.100s",
+ ttyname, (long)mode, strerror(errno));
}
}
}
===================================================================
RCS file: uidswap.c,v
retrieving revision 2.9.9.2
retrieving revision 2.9.9.2.0.1
diff -pu -r2.9.9.2 -r2.9.9.2.0.1
--- uidswap.c 2001/08/15 23:17:22 2.9.9.2
+++ uidswap.c 2001/09/28 18:37:50 2.9.9.2.0.1
@@ -52,8 +52,8 @@ temporarily_use_uid(struct passwd *pw)
#ifdef SAVED_IDS_WORK_WITH_SETEUID
saved_euid = geteuid();
saved_egid = getegid();
- debug("temporarily_use_uid: %d/%d (e=%d)",
- pw->pw_uid, pw->pw_gid, saved_euid);
+ debug("temporarily_use_uid: %ld/%ld (e=%ld)",
+ (long)pw->pw_uid, (long)pw->pw_gid, (long)saved_euid);
if (saved_euid != 0) {
privileged = 0;
return;
More information about the openssh-unix-dev
mailing list