Re: svn commit: r308432 - in head: bin/echo bin/sleep usr.bin/basename usr.bin/dc usr.bin/dirname usr.bin/fold usr.bin/getopt usr.bin/locate/bigram usr.bin/logname usr.bin/printenv usr.bin/yes

2016-11-15 Thread Jean-Sébastien Pédron
On 15.11.2016 01:24, Conrad Meyer wrote:
> Yes, this program is incorrectly capsicumized.  My mistake.  I have
> reverted the change to fold(1) in r308657.

Thank you!

-- 
Jean-Sébastien Pédron



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r308432 - in head: bin/echo bin/sleep usr.bin/basename usr.bin/dc usr.bin/dirname usr.bin/fold usr.bin/getopt usr.bin/locate/bigram usr.bin/logname usr.bin/printenv usr.bin/yes

2016-11-14 Thread Conrad Meyer
On Mon, Nov 14, 2016 at 5:25 AM, Jean-Sébastien Pédron
 wrote:
> On 08.11.2016 06:31, Conrad E. Meyer wrote:
>> Author: cem
>> Date: Tue Nov  8 05:31:01 2016
>> New Revision: 308432
>> URL: https://svnweb.freebsd.org/changeset/base/308432
>>
>> Log:
>>   Capsicumize some trivial stdio programs
>>
>>   Trivially capsicumize some simple programs that just interact with
>>   stdio.  This list of programs uses 'pledge("stdio")' in OpenBSD.
>
> Hi!
>
> fold(1) is broken after this commit:
>
> fold -s src/rabbit_ctl_usage.erl.tmp2
> fold: src/rabbit_ctl_usage.erl.tmp2: Not permitted in capability mode
>
> I don't know how Capsicum works, but fold(1) works with files in
> addition to stdio, so perhaps caph_limit_stdio() is incorrect for this
> program.

Hi,

Yes, this program is incorrectly capsicumized.  My mistake.  I have
reverted the change to fold(1) in r308657.

Thanks,
Conrad
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Re: svn commit: r308432 - in head: bin/echo bin/sleep usr.bin/basename usr.bin/dc usr.bin/dirname usr.bin/fold usr.bin/getopt usr.bin/locate/bigram usr.bin/logname usr.bin/printenv usr.bin/yes

2016-11-14 Thread Jean-Sébastien Pédron
On 08.11.2016 06:31, Conrad E. Meyer wrote:
> Author: cem
> Date: Tue Nov  8 05:31:01 2016
> New Revision: 308432
> URL: https://svnweb.freebsd.org/changeset/base/308432
> 
> Log:
>   Capsicumize some trivial stdio programs
>   
>   Trivially capsicumize some simple programs that just interact with
>   stdio.  This list of programs uses 'pledge("stdio")' in OpenBSD.

Hi!

fold(1) is broken after this commit:

fold -s src/rabbit_ctl_usage.erl.tmp2
fold: src/rabbit_ctl_usage.erl.tmp2: Not permitted in capability mode

I don't know how Capsicum works, but fold(1) works with files in
addition to stdio, so perhaps caph_limit_stdio() is incorrect for this
program.

-- 
Jean-Sébastien Pédron



signature.asc
Description: OpenPGP digital signature


svn commit: r308432 - in head: bin/echo bin/sleep usr.bin/basename usr.bin/dc usr.bin/dirname usr.bin/fold usr.bin/getopt usr.bin/locate/bigram usr.bin/logname usr.bin/printenv usr.bin/yes

2016-11-07 Thread Conrad E. Meyer
Author: cem
Date: Tue Nov  8 05:31:01 2016
New Revision: 308432
URL: https://svnweb.freebsd.org/changeset/base/308432

Log:
  Capsicumize some trivial stdio programs
  
  Trivially capsicumize some simple programs that just interact with
  stdio.  This list of programs uses 'pledge("stdio")' in OpenBSD.
  
  No objection from:allanjude, emaste, oshogbo
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D8307

Modified:
  head/bin/echo/echo.c
  head/bin/sleep/sleep.c
  head/usr.bin/basename/basename.c
  head/usr.bin/dc/dc.c
  head/usr.bin/dirname/dirname.c
  head/usr.bin/fold/fold.c
  head/usr.bin/getopt/getopt.c
  head/usr.bin/locate/bigram/locate.bigram.c
  head/usr.bin/logname/logname.c
  head/usr.bin/printenv/printenv.c
  head/usr.bin/yes/yes.c

Modified: head/bin/echo/echo.c
==
--- head/bin/echo/echo.cTue Nov  8 00:24:49 2016(r308431)
+++ head/bin/echo/echo.cTue Nov  8 05:31:01 2016(r308432)
@@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -78,6 +80,9 @@ main(int argc, char *argv[])
char newline[] = "\n";
char *progname = argv[0];
 
+   if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
+   err(1, "capsicum");
+
/* This utility may NOT do getopt(3) option parsing. */
if (*++argv && !strcmp(*argv, "-n")) {
++argv;

Modified: head/bin/sleep/sleep.c
==
--- head/bin/sleep/sleep.c  Tue Nov  8 00:24:49 2016(r308431)
+++ head/bin/sleep/sleep.c  Tue Nov  8 05:31:01 2016(r308432)
@@ -41,6 +41,7 @@ static char sccsid[] = "@(#)sleep.c   8.3 
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
 #include 
 #include 
 #include 
@@ -69,6 +70,9 @@ main(int argc, char *argv[])
time_t original;
char buf[2];
 
+   if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
+   err(1, "capsicum");
+
if (argc != 2)
usage();
 

Modified: head/usr.bin/basename/basename.c
==
--- head/usr.bin/basename/basename.cTue Nov  8 00:24:49 2016
(r308431)
+++ head/usr.bin/basename/basename.cTue Nov  8 05:31:01 2016
(r308432)
@@ -42,6 +42,7 @@ static char sccsid[] = "@(#)basename.c8
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
 #include 
 #include 
 #include 
@@ -64,6 +65,9 @@ main(int argc, char **argv)
 
setlocale(LC_ALL, "");
 
+   if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
+   err(1, "capsicum");
+
aflag = 0;
suffix = NULL;
suffixlen = 0;

Modified: head/usr.bin/dc/dc.c
==
--- head/usr.bin/dc/dc.cTue Nov  8 00:24:49 2016(r308431)
+++ head/usr.bin/dc/dc.cTue Nov  8 05:31:01 2016(r308432)
@@ -22,9 +22,11 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -58,11 +60,11 @@ usage(void)
 }
 
 static void
-procfile(char *fname) {
+procfd(int fd, char *fname) {
struct stat st;
FILE *file;
 
-   file = fopen(fname, "r");
+   file = fdopen(fd, "r");
if (file == NULL)
err(1, "cannot open file %s", fname);
if (fstat(fileno(file), ) == -1)
@@ -80,7 +82,7 @@ procfile(char *fname) {
 int
 main(int argc, char *argv[])
 {
-   int ch;
+   int ch, fd;
bool extended_regs = false, preproc_done = false;
 
/* accept and ignore a single dash to be 4.4BSD dc(1) compatible */
@@ -97,7 +99,10 @@ main(int argc, char *argv[])
case 'f':
if (!preproc_done)
init_bmachine(extended_regs);
-   procfile(optarg);
+   fd = open(optarg, O_RDONLY);
+   if (fd < 0)
+   err(1, "cannot open file %s", optarg);
+   procfd(fd, optarg);
preproc_done = true;
break;
case 'x':
@@ -126,12 +131,23 @@ main(int argc, char *argv[])
if (argc > 1)
usage();
if (argc == 1) {
-   procfile(argv[0]);
+   fd = open(argv[0], O_RDONLY);
+   if (fd < 0)
+   err(1, "cannot open file %s", argv[0]);
+
+   if (caph_limit_stream(fd, CAPH_READ) < 0 ||
+   caph_limit_stdio() < 0 ||
+   (cap_enter() < 0 && errno != ENOSYS))
+   err(1, "capsicum");
+
+   procfd(fd, argv[0]);
preproc_done