Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1 | /* |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 2 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
| 4 | * All rights reserved |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 5 | * Allocating a pseudo-terminal, and making it the controlling tty. |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 6 | * |
Damien Miller | e4340be | 2000-09-16 13:29:08 +1100 | [diff] [blame] | 7 | * As far as I am concerned, the code I have written for this software |
| 8 | * can be used freely for any purpose. Any derived versions of this |
| 9 | * software must be clearly marked as such, and if the derived work is |
| 10 | * incompatible with the protocol description in the RFC file, it must be |
| 11 | * called by a name other than "ssh" or "Secure Shell". |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 12 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 13 | |
| 14 | #include "includes.h" |
Damien Miller | f17883e | 2006-03-15 11:45:54 +1100 | [diff] [blame] | 15 | RCSID("$OpenBSD: sshpty.c,v 1.16 2006/02/20 17:19:54 stevesk Exp $"); |
Damien Miller | 17e91c0 | 2006-03-15 11:28:34 +1100 | [diff] [blame] | 16 | |
| 17 | #include <sys/ioctl.h> |
Damien Miller | f17883e | 2006-03-15 11:45:54 +1100 | [diff] [blame] | 18 | #include <sys/types.h> |
| 19 | #include <sys/stat.h> |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 20 | |
Damien Miller | 03e2003 | 2006-03-15 11:16:59 +1100 | [diff] [blame] | 21 | #ifdef HAVE_PATHS_H |
Damien Miller | a9263d0 | 2006-03-15 11:18:26 +1100 | [diff] [blame] | 22 | # include <paths.h> |
Damien Miller | 03e2003 | 2006-03-15 11:16:59 +1100 | [diff] [blame] | 23 | #endif |
| 24 | #include <termios.h> |
Damien Miller | 36b339a | 1999-12-14 10:54:47 +1100 | [diff] [blame] | 25 | #ifdef HAVE_UTIL_H |
| 26 | # include <util.h> |
| 27 | #endif /* HAVE_UTIL_H */ |
| 28 | |
Ben Lindstrom | d95c09c | 2001-02-18 19:13:33 +0000 | [diff] [blame] | 29 | #include "sshpty.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 30 | #include "log.h" |
Kevin Steves | 974fb9c | 2001-06-15 00:04:23 +0000 | [diff] [blame] | 31 | #include "misc.h" |
Damien Miller | 356a0b0 | 1999-11-08 15:30:59 +1100 | [diff] [blame] | 32 | |
Damien Miller | fce1648 | 1999-12-08 08:53:52 +1100 | [diff] [blame] | 33 | #ifdef HAVE_PTY_H |
| 34 | # include <pty.h> |
| 35 | #endif |
Damien Miller | fce1648 | 1999-12-08 08:53:52 +1100 | [diff] [blame] | 36 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 37 | #ifndef O_NOCTTY |
| 38 | #define O_NOCTTY 0 |
| 39 | #endif |
| 40 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 41 | /* |
| 42 | * Allocates and opens a pty. Returns 0 if no pty could be allocated, or |
| 43 | * nonzero if a pty was successfully allocated. On success, open file |
| 44 | * descriptors for the pty and tty sides and the name of the tty side are |
| 45 | * returned (the buffer must be able to hold at least 64 characters). |
| 46 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 47 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 48 | int |
Damien Miller | 037a0dc | 1999-12-07 15:38:31 +1100 | [diff] [blame] | 49 | pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 50 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 51 | /* openpty(3) exists in OSF/1 and some other os'es */ |
Damien Miller | 99e9243 | 2001-02-18 12:49:35 +1100 | [diff] [blame] | 52 | char *name; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 53 | int i; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 54 | |
Damien Miller | 99e9243 | 2001-02-18 12:49:35 +1100 | [diff] [blame] | 55 | i = openpty(ptyfd, ttyfd, NULL, NULL, NULL); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 56 | if (i < 0) { |
| 57 | error("openpty: %.100s", strerror(errno)); |
| 58 | return 0; |
| 59 | } |
Damien Miller | 99e9243 | 2001-02-18 12:49:35 +1100 | [diff] [blame] | 60 | name = ttyname(*ttyfd); |
| 61 | if (!name) |
| 62 | fatal("openpty returns device for which ttyname fails."); |
| 63 | |
| 64 | strlcpy(namebuf, name, namebuflen); /* possible truncation */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 65 | return 1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 66 | } |
| 67 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 68 | /* Releases the tty. Its ownership is returned to root, and permissions to 0666. */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 69 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 70 | void |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 71 | pty_release(const char *tty) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 72 | { |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 73 | if (chown(tty, (uid_t) 0, (gid_t) 0) < 0) |
| 74 | error("chown %.100s 0 0 failed: %.100s", tty, strerror(errno)); |
| 75 | if (chmod(tty, (mode_t) 0666) < 0) |
| 76 | error("chmod %.100s 0666 failed: %.100s", tty, strerror(errno)); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 77 | } |
| 78 | |
Damien Miller | 469954d | 2003-06-18 20:25:33 +1000 | [diff] [blame] | 79 | /* Makes the tty the process's controlling tty and sets it to sane modes. */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 80 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 81 | void |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 82 | pty_make_controlling_tty(int *ttyfd, const char *tty) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 83 | { |
Ben Lindstrom | 6db66ff | 2001-08-06 23:29:16 +0000 | [diff] [blame] | 84 | int fd; |
Damien Miller | 4a820ea | 2001-10-12 19:15:48 +1000 | [diff] [blame] | 85 | #ifdef USE_VHANGUP |
| 86 | void *old; |
| 87 | #endif /* USE_VHANGUP */ |
Ben Lindstrom | 6db66ff | 2001-08-06 23:29:16 +0000 | [diff] [blame] | 88 | |
Tim Rice | 81ed518 | 2002-09-25 17:38:46 -0700 | [diff] [blame] | 89 | #ifdef _UNICOS |
Kevin Steves | f744b51 | 2001-08-14 20:31:49 +0000 | [diff] [blame] | 90 | if (setsid() < 0) |
| 91 | error("setsid: %.100s", strerror(errno)); |
Ben Lindstrom | 6db66ff | 2001-08-06 23:29:16 +0000 | [diff] [blame] | 92 | |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 93 | fd = open(tty, O_RDWR|O_NOCTTY); |
Kevin Steves | f744b51 | 2001-08-14 20:31:49 +0000 | [diff] [blame] | 94 | if (fd != -1) { |
Ben Lindstrom | 5ade9ab | 2003-08-25 01:16:21 +0000 | [diff] [blame] | 95 | signal(SIGHUP, SIG_IGN); |
Kevin Steves | f744b51 | 2001-08-14 20:31:49 +0000 | [diff] [blame] | 96 | ioctl(fd, TCVHUP, (char *)NULL); |
Ben Lindstrom | 5ade9ab | 2003-08-25 01:16:21 +0000 | [diff] [blame] | 97 | signal(SIGHUP, SIG_DFL); |
Kevin Steves | f744b51 | 2001-08-14 20:31:49 +0000 | [diff] [blame] | 98 | setpgid(0, 0); |
| 99 | close(fd); |
Ben Lindstrom | 6db66ff | 2001-08-06 23:29:16 +0000 | [diff] [blame] | 100 | } else { |
Kevin Steves | f744b51 | 2001-08-14 20:31:49 +0000 | [diff] [blame] | 101 | error("Failed to disconnect from controlling tty."); |
Ben Lindstrom | 6db66ff | 2001-08-06 23:29:16 +0000 | [diff] [blame] | 102 | } |
Ben Lindstrom | 6db66ff | 2001-08-06 23:29:16 +0000 | [diff] [blame] | 103 | |
Kevin Steves | f744b51 | 2001-08-14 20:31:49 +0000 | [diff] [blame] | 104 | debug("Setting controlling tty using TCSETCTTY."); |
| 105 | ioctl(*ttyfd, TCSETCTTY, NULL); |
| 106 | fd = open("/dev/tty", O_RDWR); |
| 107 | if (fd < 0) |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 108 | error("%.100s: %.100s", tty, strerror(errno)); |
Ben Lindstrom | 6db66ff | 2001-08-06 23:29:16 +0000 | [diff] [blame] | 109 | close(*ttyfd); |
Ben Lindstrom | 5a6abda | 2002-06-09 19:41:48 +0000 | [diff] [blame] | 110 | *ttyfd = fd; |
Tim Rice | 81ed518 | 2002-09-25 17:38:46 -0700 | [diff] [blame] | 111 | #else /* _UNICOS */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 112 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 113 | /* First disconnect from the old controlling tty. */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 114 | #ifdef TIOCNOTTY |
Ben Lindstrom | 31ca54a | 2001-02-09 02:11:24 +0000 | [diff] [blame] | 115 | fd = open(_PATH_TTY, O_RDWR | O_NOCTTY); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 116 | if (fd >= 0) { |
| 117 | (void) ioctl(fd, TIOCNOTTY, NULL); |
| 118 | close(fd); |
| 119 | } |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 120 | #endif /* TIOCNOTTY */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 121 | if (setsid() < 0) |
| 122 | error("setsid: %.100s", strerror(errno)); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 123 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 124 | /* |
| 125 | * Verify that we are successfully disconnected from the controlling |
| 126 | * tty. |
| 127 | */ |
Ben Lindstrom | 31ca54a | 2001-02-09 02:11:24 +0000 | [diff] [blame] | 128 | fd = open(_PATH_TTY, O_RDWR | O_NOCTTY); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 129 | if (fd >= 0) { |
| 130 | error("Failed to disconnect from controlling tty."); |
| 131 | close(fd); |
| 132 | } |
| 133 | /* Make it our controlling tty. */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 134 | #ifdef TIOCSCTTY |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 135 | debug("Setting controlling tty using TIOCSCTTY."); |
Kevin Steves | 6c0d627 | 2000-11-12 09:22:29 +0000 | [diff] [blame] | 136 | if (ioctl(*ttyfd, TIOCSCTTY, NULL) < 0) |
| 137 | error("ioctl(TIOCSCTTY): %.100s", strerror(errno)); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 138 | #endif /* TIOCSCTTY */ |
Darren Tucker | 2be1cbb | 2005-05-27 21:13:40 +1000 | [diff] [blame] | 139 | #ifdef NEED_SETPGRP |
Ben Lindstrom | b562864 | 2000-10-18 00:02:25 +0000 | [diff] [blame] | 140 | if (setpgrp(0,0) < 0) |
| 141 | error("SETPGRP %s",strerror(errno)); |
Darren Tucker | 2be1cbb | 2005-05-27 21:13:40 +1000 | [diff] [blame] | 142 | #endif /* NEED_SETPGRP */ |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 143 | #ifdef USE_VHANGUP |
Ben Lindstrom | 5ade9ab | 2003-08-25 01:16:21 +0000 | [diff] [blame] | 144 | old = signal(SIGHUP, SIG_IGN); |
Damien Miller | d0cff3e | 2000-04-20 23:12:58 +1000 | [diff] [blame] | 145 | vhangup(); |
Ben Lindstrom | 5ade9ab | 2003-08-25 01:16:21 +0000 | [diff] [blame] | 146 | signal(SIGHUP, old); |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 147 | #endif /* USE_VHANGUP */ |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 148 | fd = open(tty, O_RDWR); |
Damien Miller | d0cff3e | 2000-04-20 23:12:58 +1000 | [diff] [blame] | 149 | if (fd < 0) { |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 150 | error("%.100s: %.100s", tty, strerror(errno)); |
Damien Miller | d0cff3e | 2000-04-20 23:12:58 +1000 | [diff] [blame] | 151 | } else { |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 152 | #ifdef USE_VHANGUP |
Damien Miller | d0cff3e | 2000-04-20 23:12:58 +1000 | [diff] [blame] | 153 | close(*ttyfd); |
| 154 | *ttyfd = fd; |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 155 | #else /* USE_VHANGUP */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 156 | close(fd); |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 157 | #endif /* USE_VHANGUP */ |
Damien Miller | d0cff3e | 2000-04-20 23:12:58 +1000 | [diff] [blame] | 158 | } |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 159 | /* Verify that we now have a controlling tty. */ |
Ben Lindstrom | 31ca54a | 2001-02-09 02:11:24 +0000 | [diff] [blame] | 160 | fd = open(_PATH_TTY, O_WRONLY); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 161 | if (fd < 0) |
| 162 | error("open /dev/tty failed - could not set controlling tty: %.100s", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 163 | strerror(errno)); |
Damien Miller | a8e06ce | 2003-11-21 23:48:55 +1100 | [diff] [blame] | 164 | else |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 165 | close(fd); |
Tim Rice | 81ed518 | 2002-09-25 17:38:46 -0700 | [diff] [blame] | 166 | #endif /* _UNICOS */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | /* Changes the window size associated with the pty. */ |
| 170 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 171 | void |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 172 | pty_change_window_size(int ptyfd, int row, int col, |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 173 | int xpixel, int ypixel) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 174 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 175 | struct winsize w; |
Ben Lindstrom | 8ada5d0 | 2002-06-23 21:42:50 +0000 | [diff] [blame] | 176 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 177 | w.ws_row = row; |
| 178 | w.ws_col = col; |
| 179 | w.ws_xpixel = xpixel; |
| 180 | w.ws_ypixel = ypixel; |
| 181 | (void) ioctl(ptyfd, TIOCSWINSZ, &w); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 182 | } |
Damien Miller | c7d8dbb | 2000-03-02 23:30:53 +1100 | [diff] [blame] | 183 | |
| 184 | void |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 185 | pty_setowner(struct passwd *pw, const char *tty) |
Damien Miller | c7d8dbb | 2000-03-02 23:30:53 +1100 | [diff] [blame] | 186 | { |
| 187 | struct group *grp; |
| 188 | gid_t gid; |
| 189 | mode_t mode; |
Kevin Steves | fa72dda | 2000-12-15 18:39:12 +0000 | [diff] [blame] | 190 | struct stat st; |
Damien Miller | c7d8dbb | 2000-03-02 23:30:53 +1100 | [diff] [blame] | 191 | |
| 192 | /* Determine the group to make the owner of the tty. */ |
| 193 | grp = getgrnam("tty"); |
| 194 | if (grp) { |
| 195 | gid = grp->gr_gid; |
| 196 | mode = S_IRUSR | S_IWUSR | S_IWGRP; |
| 197 | } else { |
| 198 | gid = pw->pw_gid; |
| 199 | mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; |
| 200 | } |
| 201 | |
Kevin Steves | fa72dda | 2000-12-15 18:39:12 +0000 | [diff] [blame] | 202 | /* |
| 203 | * Change owner and mode of the tty as required. |
Ben Lindstrom | c88785e | 2001-08-06 20:47:23 +0000 | [diff] [blame] | 204 | * Warn but continue if filesystem is read-only and the uids match/ |
| 205 | * tty is owned by root. |
Kevin Steves | fa72dda | 2000-12-15 18:39:12 +0000 | [diff] [blame] | 206 | */ |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 207 | if (stat(tty, &st)) |
| 208 | fatal("stat(%.100s) failed: %.100s", tty, |
Kevin Steves | fa72dda | 2000-12-15 18:39:12 +0000 | [diff] [blame] | 209 | strerror(errno)); |
| 210 | |
| 211 | if (st.st_uid != pw->pw_uid || st.st_gid != gid) { |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 212 | if (chown(tty, pw->pw_uid, gid) < 0) { |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 213 | if (errno == EROFS && |
Ben Lindstrom | 8ada5d0 | 2002-06-23 21:42:50 +0000 | [diff] [blame] | 214 | (st.st_uid == pw->pw_uid || st.st_uid == 0)) |
Damien Miller | e8cea9e | 2003-02-24 11:54:10 +1100 | [diff] [blame] | 215 | debug("chown(%.100s, %u, %u) failed: %.100s", |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 216 | tty, (u_int)pw->pw_uid, (u_int)gid, |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 217 | strerror(errno)); |
Kevin Steves | fa72dda | 2000-12-15 18:39:12 +0000 | [diff] [blame] | 218 | else |
Ben Lindstrom | 5c38552 | 2002-06-23 21:23:20 +0000 | [diff] [blame] | 219 | fatal("chown(%.100s, %u, %u) failed: %.100s", |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 220 | tty, (u_int)pw->pw_uid, (u_int)gid, |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 221 | strerror(errno)); |
Kevin Steves | fa72dda | 2000-12-15 18:39:12 +0000 | [diff] [blame] | 222 | } |
| 223 | } |
| 224 | |
| 225 | if ((st.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO)) != mode) { |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 226 | if (chmod(tty, mode) < 0) { |
Kevin Steves | fa72dda | 2000-12-15 18:39:12 +0000 | [diff] [blame] | 227 | if (errno == EROFS && |
| 228 | (st.st_mode & (S_IRGRP | S_IROTH)) == 0) |
Damien Miller | e8cea9e | 2003-02-24 11:54:10 +1100 | [diff] [blame] | 229 | debug("chmod(%.100s, 0%o) failed: %.100s", |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 230 | tty, (u_int)mode, strerror(errno)); |
Kevin Steves | fa72dda | 2000-12-15 18:39:12 +0000 | [diff] [blame] | 231 | else |
| 232 | fatal("chmod(%.100s, 0%o) failed: %.100s", |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 233 | tty, (u_int)mode, strerror(errno)); |
Kevin Steves | fa72dda | 2000-12-15 18:39:12 +0000 | [diff] [blame] | 234 | } |
| 235 | } |
Damien Miller | c7d8dbb | 2000-03-02 23:30:53 +1100 | [diff] [blame] | 236 | } |