{
int fd;
int r;
+ struct stat buf;
+
+ /* RHBZ#582484: Restrict touch to regular files. It's also OK
+ * here if the file does not exist, since we will create it.
+ */
+ CHROOT_IN;
+ r = lstat (path, &buf);
+ CHROOT_OUT;
+
+ if (r == -1) {
+ if (errno != ENOENT) {
+ reply_with_perror ("lstat: %s", path);
+ return -1;
+ }
+ } else {
+ if (! S_ISREG (buf.st_mode)) {
+ reply_with_error ("%s: touch can only be used on a regular files", path);
+ return -1;
+ }
+ }
CHROOT_IN;
fd = open (path, O_WRONLY | O_CREAT | O_NOCTTY, 0666);
"\
Touch acts like the L<touch(1)> command. It can be used to
update the timestamps on a file, or, if the file does not exist,
-to create a new zero-length file.");
+to create a new zero-length file.
+
+This command only works on regular files, and will fail on other
+file types such as directories, symbolic links, block special etc.");
("cat", (RString "content", [Pathname "path"]), 4, [ProtocolLimitWarning],
[InitISOFS, Always, TestOutput (