From: semarie Date: Thu, 14 Jul 2016 08:31:18 +0000 (+0000) Subject: make several program to use "chown" promise. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1eacd88933d1d200f8cda199641ece0107aa3c81;p=openbsd make several program to use "chown" promise. it allows chown(2) call to change the user or group on a file. - usr.bin/compress : aka gzip - usr.bin/mg : open a file for writing - usr.bin/sed : inplace editing - usr.bin/sort : if outfile equals one of the input files ok deraadt@ tb@ (and a reminder from Remi Locherer) warning: in order to use it, you must have a recent kernel with the new promise. --- diff --git a/usr.bin/compress/main.c b/usr.bin/compress/main.c index c359ba0e059..9fc265fa7c0 100644 --- a/usr.bin/compress/main.c +++ b/usr.bin/compress/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.90 2015/10/17 21:34:07 naddy Exp $ */ +/* $OpenBSD: main.c,v 1.91 2016/07/14 08:31:18 semarie Exp $ */ /* * Copyright (c) 1992, 1993 @@ -167,7 +167,7 @@ main(int argc, char *argv[]) char outfile[PATH_MAX], _infile[PATH_MAX], suffix[16]; int bits, ch, error, rc, cflag, oflag; - if (pledge("stdio rpath wpath cpath fattr", NULL) == -1) + if (pledge("stdio rpath wpath cpath fattr chown", NULL) == -1) err(1, "pledge"); bits = cflag = oflag = 0; diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c index 1ac6c6acdcb..22f50cf25fa 100644 --- a/usr.bin/mg/main.c +++ b/usr.bin/mg/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.82 2016/04/14 17:05:32 lum Exp $ */ +/* $OpenBSD: main.c,v 1.83 2016/07/14 08:31:18 semarie Exp $ */ /* This file is in the public domain. */ @@ -57,7 +57,8 @@ main(int argc, char **argv) int nobackups = 0, bro = 0; struct buffer *bp = NULL; - if (pledge("stdio rpath wpath cpath fattr getpw tty proc exec", NULL) == -1) + if (pledge("stdio rpath wpath cpath fattr chown getpw tty proc exec", + NULL) == -1) err(1, "pledge"); while ((o = getopt(argc, argv, "nRf:")) != -1) diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index 62c2b4ecd85..cddafbbd4f5 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.32 2016/03/17 05:27:10 bentley Exp $ */ +/* $OpenBSD: main.c,v 1.33 2016/07/14 08:31:18 semarie Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -160,7 +160,7 @@ main(int argc, char *argv[]) termwidth = 80; if (inplace != NULL) { - if (pledge("stdio rpath wpath cpath fattr", NULL) == -1) + if (pledge("stdio rpath wpath cpath fattr chown", NULL) == -1) error(FATAL, "pledge: %s", strerror(errno)); } else { if (pledge("stdio rpath wpath cpath", NULL) == -1) diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c index 0b349f0d898..d986cb23365 100644 --- a/usr.bin/sort/sort.c +++ b/usr.bin/sort/sort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sort.c,v 1.85 2015/10/24 15:19:01 millert Exp $ */ +/* $OpenBSD: sort.c,v 1.86 2016/07/14 08:31:18 semarie Exp $ */ /*- * Copyright (C) 2009 Gabor Kovesdan @@ -870,7 +870,7 @@ main(int argc, char *argv[]) set_hw_params(); - if (pledge("stdio rpath wpath cpath fattr proc exec", NULL) == -1) + if (pledge("stdio rpath wpath cpath fattr chown proc exec", NULL) == -1) err(2, "pledge"); outfile = "-"; @@ -1053,7 +1053,7 @@ main(int argc, char *argv[]) argv += optind; if (compress_program == NULL) { - if (pledge("stdio rpath wpath cpath fattr", NULL) == -1) + if (pledge("stdio rpath wpath cpath fattr chown", NULL) == -1) err(2, "pledge"); }