summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2004-01-21 17:07:16 +1100
committerDamien Miller <djm@mindrot.org>2004-01-21 17:07:16 +1100
commitf4da3bb6cadcb26fd6edd19887b5187c13724255 (patch)
tree5dafba6910263101b9d869bd84591a125aea90d2
parente4f5a82d6e4748a99fef33a08986392742cc27c8 (diff)
- deraadt@cvs.openbsd.org 2004/01/11 21:55:06
[sshpty.c] for pty opening, only use the openpty() path. the other stuff only needs to be in openssh-p; markus ok - (djm) [openbsd-compat/bsd-openpty.c] Rework old sshpty.c code into an openpty() replacement
-rw-r--r--ChangeLog8
-rw-r--r--openbsd-compat/Makefile.in4
-rw-r--r--openbsd-compat/bsd-openpty.c211
-rw-r--r--openbsd-compat/openbsd-compat.h7
-rw-r--r--sshpty.c192
5 files changed, 225 insertions, 197 deletions
diff --git a/ChangeLog b/ChangeLog
index 8cebcce96..dff32c6cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,6 +26,12 @@
26 - djm@cvs.openbsd.org 2004/01/21 03:07:59 26 - djm@cvs.openbsd.org 2004/01/21 03:07:59
27 [sftp.c] 27 [sftp.c]
28 initialise infile in main, rather than statically - from portable 28 initialise infile in main, rather than statically - from portable
29 - deraadt@cvs.openbsd.org 2004/01/11 21:55:06
30 [sshpty.c]
31 for pty opening, only use the openpty() path. the other stuff only needs
32 to be in openssh-p; markus ok
33 - (djm) [openbsd-compat/bsd-openpty.c] Rework old sshpty.c code into an
34 openpty() replacement
29 35
3020040114 3620040114
31 - (dtucker) [auth-pam.c] Have monitor die if PAM authentication thread exits 37 - (dtucker) [auth-pam.c] Have monitor die if PAM authentication thread exits
@@ -1695,4 +1701,4 @@
1695 - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. 1701 - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
1696 Report from murple@murple.net, diagnosis from dtucker@zip.com.au 1702 Report from murple@murple.net, diagnosis from dtucker@zip.com.au
1697 1703
1698$Id: ChangeLog,v 1.3176 2004/01/21 03:11:05 djm Exp $ 1704$Id: ChangeLog,v 1.3177 2004/01/21 06:07:16 djm Exp $
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in
index de9856eea..5de20abbc 100644
--- a/openbsd-compat/Makefile.in
+++ b/openbsd-compat/Makefile.in
@@ -1,4 +1,4 @@
1# $Id: Makefile.in,v 1.29 2003/10/07 07:49:57 dtucker Exp $ 1# $Id: Makefile.in,v 1.30 2004/01/21 06:07:23 djm Exp $
2 2
3sysconfdir=@sysconfdir@ 3sysconfdir=@sysconfdir@
4piddir=@piddir@ 4piddir=@piddir@
@@ -18,7 +18,7 @@ LDFLAGS=-L. @LDFLAGS@
18 18
19OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtoul.o vis.o 19OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtoul.o vis.o
20 20
21COMPAT=bsd-arc4random.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o xmmap.o xcrypt.o 21COMPAT=bsd-arc4random.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o xmmap.o xcrypt.o
22 22
23PORTS=port-irix.o port-aix.o 23PORTS=port-irix.o port-aix.o
24 24
diff --git a/openbsd-compat/bsd-openpty.c b/openbsd-compat/bsd-openpty.c
new file mode 100644
index 000000000..0a3c5e211
--- /dev/null
+++ b/openbsd-compat/bsd-openpty.c
@@ -0,0 +1,211 @@
1/*
2 * Please note: this implementation of openpty() is far from complete.
3 * it is just enough for portable OpenSSH's needs.
4 */
5
6/*
7 * Copyright (c) 2004 Damien Miller. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/*
31 * Author: Tatu Ylonen <ylo@cs.hut.fi>
32 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
33 * All rights reserved
34 * Allocating a pseudo-terminal, and making it the controlling tty.
35 *
36 * As far as I am concerned, the code I have written for this software
37 * can be used freely for any purpose. Any derived versions of this
38 * software must be clearly marked as such, and if the derived work is
39 * incompatible with the protocol description in the RFC file, it must be
40 * called by a name other than "ssh" or "Secure Shell".
41 */
42
43#include "includes.h"
44#if !defined(HAVE_OPENPTY)
45
46#ifdef HAVE_UTIL_H
47# include <util.h>
48#endif /* HAVE_UTIL_H */
49
50#ifdef HAVE_PTY_H
51# include <pty.h>
52#endif
53#if defined(HAVE_DEV_PTMX) && defined(HAVE_SYS_STROPTS_H)
54# include <sys/stropts.h>
55#endif
56
57#ifndef O_NOCTTY
58#define O_NOCTTY 0
59#endif
60
61int
62openpty(int *amaster, int *aslave, char *name, struct termios *termp,
63 struct winsize *winp)
64{
65#if defined(HAVE__GETPTY)
66 /*
67 * _getpty(3) exists in SGI Irix 4.x, 5.x & 6.x -- it generates more
68 * pty's automagically when needed
69 */
70 char *slave;
71
72 if ((slave = _getpty(amaster, O_RDWR, 0622, 0)) == NULL)
73 return (-1);
74
75 /* Open the slave side. */
76 if ((*aslave = open(slave, O_RDWR | O_NOCTTY)) == -1) {
77 close(*amaster);
78 return (-1);
79 }
80 return (0);
81
82#elif defined(HAVE_DEV_PTMX)
83 /*
84 * This code is used e.g. on Solaris 2.x. (Note that Solaris 2.3
85 * also has bsd-style ptys, but they simply do not work.)
86 */
87 int ptm;
88 char *pts;
89 mysig_t old_signal;
90
91 if ((ptm = open("/dev/ptmx", O_RDWR | O_NOCTTY)) == -1)
92 return (-1);
93
94 /* XXX: need to close ptm on error? */
95 old_signal = signal(SIGCHLD, SIG_DFL);
96 if (grantpt(ptm) < 0)
97 return (-1);
98 signal(SIGCHLD, old_signal);
99
100 if (unlockpt(ptm) < 0)
101 return (-1);
102
103 if ((pts = ptsname(ptm)) == NULL)
104 return (-1);
105 *amaster = ptm;
106
107 /* Open the slave side. */
108 if ((*aslave = open(pts, O_RDWR | O_NOCTTY)) == -1) {
109 close(*amaster);
110 return (-1);
111 }
112
113#ifndef HAVE_CYGWIN
114 /*
115 * Try to push the appropriate streams modules, as described
116 * in Solaris pts(7).
117 */
118 ioctl(*aslave, I_PUSH, "ptem");
119 ioctl(*aslave, I_PUSH, "ldterm");
120# ifndef __hpux
121 ioctl(*aslave, I_PUSH, "ttcompat");
122# endif /* __hpux */
123#endif /* HAVE_CYGWIN */
124
125 return (0);
126
127#elif defined(HAVE_DEV_PTS_AND_PTC)
128 /* AIX-style pty code. */
129 const char *ttname;
130
131 if ((*amaster = open("/dev/ptc", O_RDWR | O_NOCTTY)) == -1)
132 return (-1);
133 if ((ttname = ttyname(*amaster)) == NULL)
134 return (-1);
135 if ((*aslave = open(ttname, O_RDWR | O_NOCTTY)) == -1) {
136 close(*amaster);
137 return (-1);
138 }
139 return (0);
140
141#elif defined(_UNICOS)
142 char ptbuf[64], ttbuf[64];
143 int i;
144 int highpty;
145
146 highpty = 128;
147#ifdef _SC_CRAY_NPTY
148 if ((highpty = sysconf(_SC_CRAY_NPTY)) == -1)
149 highpty = 128;
150#endif /* _SC_CRAY_NPTY */
151
152 for (i = 0; i < highpty; i++) {
153 snprintf(ptbuf, sizeof(ptbuf), "/dev/pty/%03d", i);
154 snprintf(ttbuf, sideof(ttbuf), "/dev/ttyp%03d", i);
155 if ((*amaster = open(ptbuf, O_RDWR|O_NOCTTY)) == -1)
156 continue;
157 /* Open the slave side. */
158 if ((*aslave = open(ttbuf, O_RDWR|O_NOCTTY)) == -1) {
159 close(*amaster);
160 return (-1);
161 }
162 return (0);
163 }
164 return (-1);
165
166#else
167 /* BSD-style pty code. */
168 char ptbuf[64], ttbuf[64];
169 int i;
170 const char *ptymajors = "pqrstuvwxyzabcdefghijklmno"
171 "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
172 const char *ptyminors = "0123456789abcdef";
173 int num_minors = strlen(ptyminors);
174 int num_ptys = strlen(ptymajors) * num_minors;
175 struct termios tio;
176
177 for (i = 0; i < num_ptys; i++) {
178 snprintf(ptbuf, sizeof(ptbuf), "/dev/pty%c%c",
179 ptymajors[i / num_minors], ptyminors[i % num_minors]);
180 snprintf(ttbuf, sizeof(ttbuf), "/dev/tty%c%c",
181 ptymajors[i / num_minors], ptyminors[i % num_minors]);
182
183 if ((*amaster = open(ptbuf, O_RDWR | O_NOCTTY)) == -1) {
184 /* Try SCO style naming */
185 snprintf(ptbuf, sizeof(ptbuf), "/dev/ptyp%d", i);
186 snprintf(ttbuf, sizeof(ttbuf), "/dev/ttyp%d", i);
187 if ((*amaster = open(ptbuf, O_RDWR | O_NOCTTY)) == -1)
188 continue;
189 }
190
191 /* Open the slave side. */
192 if ((*aslave = open(ttbuf, O_RDWR | O_NOCTTY)) == -1) {
193 close(*amaster);
194 return (-1);
195 }
196 /* set tty modes to a sane state for broken clients */
197 if (tcgetattr(*amaster, &tio) != -1) {
198 tio.c_lflag |= (ECHO | ISIG | ICANON);
199 tio.c_oflag |= (OPOST | ONLCR);
200 tio.c_iflag |= ICRNL;
201 tcsetattr(*amaster, TCSANOW, &tio);
202 }
203
204 return (0);
205 }
206 return (-1);
207#endif
208}
209
210#endif /* !defined(HAVE_OPENPTY) */
211
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h
index 852948c54..6be1bcda4 100644
--- a/openbsd-compat/openbsd-compat.h
+++ b/openbsd-compat/openbsd-compat.h
@@ -1,4 +1,4 @@
1/* $Id: openbsd-compat.h,v 1.24 2003/08/29 16:59:52 mouring Exp $ */ 1/* $Id: openbsd-compat.h,v 1.25 2004/01/21 06:07:23 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999-2003 Damien Miller. All rights reserved. 4 * Copyright (c) 1999-2003 Damien Miller. All rights reserved.
@@ -138,8 +138,9 @@ unsigned int arc4random(void);
138void arc4random_stir(void); 138void arc4random_stir(void);
139#endif /* !HAVE_ARC4RANDOM */ 139#endif /* !HAVE_ARC4RANDOM */
140 140
141 141#ifndef HAVE_OPENPTY
142 142int openpty(int *, int *, char *, struct termios *, struct winsize *);
143#endif /* HAVE_OPENPTY */
143 144
144/* #include <sys/types.h> XXX needed? For size_t */ 145/* #include <sys/types.h> XXX needed? For size_t */
145 146
diff --git a/sshpty.c b/sshpty.c
index 50b1f2ba3..0fe3891b6 100644
--- a/sshpty.c
+++ b/sshpty.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: sshpty.c,v 1.10 2003/06/12 07:57:38 markus Exp $"); 15RCSID("$OpenBSD: sshpty.c,v 1.11 2004/01/11 21:55:06 deraadt Exp $");
16 16
17#ifdef HAVE_UTIL_H 17#ifdef HAVE_UTIL_H
18# include <util.h> 18# include <util.h>
@@ -22,17 +22,9 @@ RCSID("$OpenBSD: sshpty.c,v 1.10 2003/06/12 07:57:38 markus Exp $");
22#include "log.h" 22#include "log.h"
23#include "misc.h" 23#include "misc.h"
24 24
25/* Pty allocated with _getpty gets broken if we do I_PUSH:es to it. */
26#if defined(HAVE__GETPTY) || defined(HAVE_OPENPTY)
27#undef HAVE_DEV_PTMX
28#endif
29
30#ifdef HAVE_PTY_H 25#ifdef HAVE_PTY_H
31# include <pty.h> 26# include <pty.h>
32#endif 27#endif
33#if defined(HAVE_DEV_PTMX) && defined(HAVE_SYS_STROPTS_H)
34# include <sys/stropts.h>
35#endif
36 28
37#ifndef O_NOCTTY 29#ifndef O_NOCTTY
38#define O_NOCTTY 0 30#define O_NOCTTY 0
@@ -48,7 +40,6 @@ RCSID("$OpenBSD: sshpty.c,v 1.10 2003/06/12 07:57:38 markus Exp $");
48int 40int
49pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) 41pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
50{ 42{
51#if defined(HAVE_OPENPTY) || defined(BSD4_4)
52 /* openpty(3) exists in OSF/1 and some other os'es */ 43 /* openpty(3) exists in OSF/1 and some other os'es */
53 char *name; 44 char *name;
54 int i; 45 int i;
@@ -64,187 +55,6 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
64 55
65 strlcpy(namebuf, name, namebuflen); /* possible truncation */ 56 strlcpy(namebuf, name, namebuflen); /* possible truncation */
66 return 1; 57 return 1;
67#else /* HAVE_OPENPTY */
68#ifdef HAVE__GETPTY
69 /*
70 * _getpty(3) exists in SGI Irix 4.x, 5.x & 6.x -- it generates more
71 * pty's automagically when needed
72 */
73 char *slave;
74
75 slave = _getpty(ptyfd, O_RDWR, 0622, 0);
76 if (slave == NULL) {
77 error("_getpty: %.100s", strerror(errno));
78 return 0;
79 }
80 strlcpy(namebuf, slave, namebuflen);
81 /* Open the slave side. */
82 *ttyfd = open(namebuf, O_RDWR | O_NOCTTY);
83 if (*ttyfd < 0) {
84 error("%.200s: %.100s", namebuf, strerror(errno));
85 close(*ptyfd);
86 return 0;
87 }
88 return 1;
89#else /* HAVE__GETPTY */
90#if defined(HAVE_DEV_PTMX)
91 /*
92 * This code is used e.g. on Solaris 2.x. (Note that Solaris 2.3
93 * also has bsd-style ptys, but they simply do not work.)
94 */
95 int ptm;
96 char *pts;
97 mysig_t old_signal;
98
99 ptm = open("/dev/ptmx", O_RDWR | O_NOCTTY);
100 if (ptm < 0) {
101 error("/dev/ptmx: %.100s", strerror(errno));
102 return 0;
103 }
104 old_signal = signal(SIGCHLD, SIG_DFL);
105 if (grantpt(ptm) < 0) {
106 error("grantpt: %.100s", strerror(errno));
107 return 0;
108 }
109 signal(SIGCHLD, old_signal);
110 if (unlockpt(ptm) < 0) {
111 error("unlockpt: %.100s", strerror(errno));
112 return 0;
113 }
114 pts = ptsname(ptm);
115 if (pts == NULL)
116 error("Slave pty side name could not be obtained.");
117 strlcpy(namebuf, pts, namebuflen);
118 *ptyfd = ptm;
119
120 /* Open the slave side. */
121 *ttyfd = open(namebuf, O_RDWR | O_NOCTTY);
122 if (*ttyfd < 0) {
123 error("%.100s: %.100s", namebuf, strerror(errno));
124 close(*ptyfd);
125 return 0;
126 }
127#ifndef HAVE_CYGWIN
128 /*
129 * Push the appropriate streams modules, as described in Solaris pts(7).
130 * HP-UX pts(7) doesn't have ttcompat module.
131 */
132 if (ioctl(*ttyfd, I_PUSH, "ptem") < 0)
133 error("ioctl I_PUSH ptem: %.100s", strerror(errno));
134 if (ioctl(*ttyfd, I_PUSH, "ldterm") < 0)
135 error("ioctl I_PUSH ldterm: %.100s", strerror(errno));
136#ifndef __hpux
137 if (ioctl(*ttyfd, I_PUSH, "ttcompat") < 0)
138 error("ioctl I_PUSH ttcompat: %.100s", strerror(errno));
139#endif
140#endif
141 return 1;
142#else /* HAVE_DEV_PTMX */
143#ifdef HAVE_DEV_PTS_AND_PTC
144 /* AIX-style pty code. */
145 const char *name;
146
147 *ptyfd = open("/dev/ptc", O_RDWR | O_NOCTTY);
148 if (*ptyfd < 0) {
149 error("Could not open /dev/ptc: %.100s", strerror(errno));
150 return 0;
151 }
152 name = ttyname(*ptyfd);
153 if (!name)
154 fatal("Open of /dev/ptc returns device for which ttyname fails.");
155 strlcpy(namebuf, name, namebuflen);
156 *ttyfd = open(name, O_RDWR | O_NOCTTY);
157 if (*ttyfd < 0) {
158 error("Could not open pty slave side %.100s: %.100s",
159 name, strerror(errno));
160 close(*ptyfd);
161 return 0;
162 }
163 return 1;
164#else /* HAVE_DEV_PTS_AND_PTC */
165#ifdef _UNICOS
166 char buf[64];
167 int i;
168 int highpty;
169
170#ifdef _SC_CRAY_NPTY
171 highpty = sysconf(_SC_CRAY_NPTY);
172 if (highpty == -1)
173 highpty = 128;
174#else
175 highpty = 128;
176#endif
177
178 for (i = 0; i < highpty; i++) {
179 snprintf(buf, sizeof(buf), "/dev/pty/%03d", i);
180 *ptyfd = open(buf, O_RDWR|O_NOCTTY);
181 if (*ptyfd < 0)
182 continue;
183 snprintf(namebuf, namebuflen, "/dev/ttyp%03d", i);
184 /* Open the slave side. */
185 *ttyfd = open(namebuf, O_RDWR|O_NOCTTY);
186 if (*ttyfd < 0) {
187 error("%.100s: %.100s", namebuf, strerror(errno));
188 close(*ptyfd);
189 return 0;
190 }
191 return 1;
192 }
193 return 0;
194#else
195 /* BSD-style pty code. */
196 char buf[64];
197 int i;
198 const char *ptymajors = "pqrstuvwxyzabcdefghijklmnoABCDEFGHIJKLMNOPQRSTUVWXYZ";
199 const char *ptyminors = "0123456789abcdef";
200 int num_minors = strlen(ptyminors);
201 int num_ptys = strlen(ptymajors) * num_minors;
202 struct termios tio;
203
204 for (i = 0; i < num_ptys; i++) {
205 snprintf(buf, sizeof buf, "/dev/pty%c%c", ptymajors[i / num_minors],
206 ptyminors[i % num_minors]);
207 snprintf(namebuf, namebuflen, "/dev/tty%c%c",
208 ptymajors[i / num_minors], ptyminors[i % num_minors]);
209
210 *ptyfd = open(buf, O_RDWR | O_NOCTTY);
211 if (*ptyfd < 0) {
212 /* Try SCO style naming */
213 snprintf(buf, sizeof buf, "/dev/ptyp%d", i);
214 snprintf(namebuf, namebuflen, "/dev/ttyp%d", i);
215 *ptyfd = open(buf, O_RDWR | O_NOCTTY);
216 if (*ptyfd < 0)
217 continue;
218 }
219
220 /* Open the slave side. */
221 *ttyfd = open(namebuf, O_RDWR | O_NOCTTY);
222 if (*ttyfd < 0) {
223 error("%.100s: %.100s", namebuf, strerror(errno));
224 close(*ptyfd);
225 return 0;
226 }
227 /* set tty modes to a sane state for broken clients */
228 if (tcgetattr(*ptyfd, &tio) < 0)
229 logit("Getting tty modes for pty failed: %.100s", strerror(errno));
230 else {
231 tio.c_lflag |= (ECHO | ISIG | ICANON);
232 tio.c_oflag |= (OPOST | ONLCR);
233 tio.c_iflag |= ICRNL;
234
235 /* Set the new modes for the terminal. */
236 if (tcsetattr(*ptyfd, TCSANOW, &tio) < 0)
237 logit("Setting tty modes for pty failed: %.100s", strerror(errno));
238 }
239
240 return 1;
241 }
242 return 0;
243#endif /* CRAY */
244#endif /* HAVE_DEV_PTS_AND_PTC */
245#endif /* HAVE_DEV_PTMX */
246#endif /* HAVE__GETPTY */
247#endif /* HAVE_OPENPTY */
248} 58}
249 59
250/* Releases the tty. Its ownership is returned to root, and permissions to 0666. */ 60/* Releases the tty. Its ownership is returned to root, and permissions to 0666. */