Fri Jan 7 16:02:32 2011 UTC ()
Make P2K_WIZARDUID require a valid integer instead of defaulting to root.


(pooka)
diff -r1.9 -r1.10 src/lib/libp2k/p2k.3
diff -r1.53 -r1.54 src/lib/libp2k/p2k.c

cvs diff -r1.9 -r1.10 src/lib/libp2k/p2k.3 (expand / switch to unified diff)

--- src/lib/libp2k/p2k.3 2011/01/07 15:50:40 1.9
+++ src/lib/libp2k/p2k.3 2011/01/07 16:02:32 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: p2k.3,v 1.9 2011/01/07 15:50:40 pooka Exp $ 1.\" $NetBSD: p2k.3,v 1.10 2011/01/07 16:02:32 pooka Exp $
2.\" 2.\"
3.\" Copyright (c) 2008 Antti Kantee. All rights reserved. 3.\" Copyright (c) 2008 Antti Kantee. All rights reserved.
4.\" 4.\"
5.\" Redistribution and use in source and binary forms, with or without 5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions 6.\" modification, are permitted provided that the following conditions
7.\" are met: 7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright 8.\" 1. Redistributions of source code must retain the above copyright
9.\" notice, this list of conditions and the following disclaimer. 9.\" notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\" notice, this list of conditions and the following disclaimer in the 11.\" notice, this list of conditions and the following disclaimer in the
12.\" documentation and/or other materials provided with the distribution. 12.\" documentation and/or other materials provided with the distribution.
13.\" 13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
@@ -108,30 +108,28 @@ Sending @@ -108,30 +108,28 @@ Sending
108causes a dump of all the vnodes (verbose). 108causes a dump of all the vnodes (verbose).
109.It Dv P2K_NODETACH 109.It Dv P2K_NODETACH
110Do not detach from tty. 110Do not detach from tty.
111.It Dv P2K_NOCACHE_PAGE 111.It Dv P2K_NOCACHE_PAGE
112Do not use the puffs page cache. 112Do not use the puffs page cache.
113.It Dv P2K_NOCACHE_NAME 113.It Dv P2K_NOCACHE_NAME
114Do not use the puffs name cache. 114Do not use the puffs name cache.
115.It Dv P2K_NOCACHE 115.It Dv P2K_NOCACHE
116Do not use the puffs page or name cache. 116Do not use the puffs page or name cache.
117.It Dv P2K_WIZARDUID 117.It Dv P2K_WIZARDUID
118If set, use the value of the variable to determine the UID of the 118If set, use the value of the variable to determine the UID of the
119caller of each operation instead of the actual caller supplied by 119caller of each operation instead of the actual caller supplied by
120.Xr puffs 3 . 120.Xr puffs 3 .
121This can be used for example to simplify modifying an OS installations 121This can be used for example to simplify modifying an OS installation's
122root image as a non-root user. 122root image as a non-root user.
123If the variable is set but does not contain an integer value, 0 
124(root) is used. 
125.El 123.El
126.Sh SEE ALSO 124.Sh SEE ALSO
127.Xr puffs 3 , 125.Xr puffs 3 ,
128.Xr rump 3 , 126.Xr rump 3 ,
129.Xr ukfs 3 , 127.Xr ukfs 3 ,
130.Xr rump_cd9660 8 , 128.Xr rump_cd9660 8 ,
131.Xr rump_efs 8 , 129.Xr rump_efs 8 ,
132.Xr rump_ext2fs 8 , 130.Xr rump_ext2fs 8 ,
133.Xr rump_ffs 8 , 131.Xr rump_ffs 8 ,
134.Xr rump_hfs 8 , 132.Xr rump_hfs 8 ,
135.Xr rump_lfs 8 , 133.Xr rump_lfs 8 ,
136.Xr rump_msdos 8 , 134.Xr rump_msdos 8 ,
137.Xr rump_nfs 8 , 135.Xr rump_nfs 8 ,

cvs diff -r1.53 -r1.54 src/lib/libp2k/p2k.c (expand / switch to unified diff)

--- src/lib/libp2k/p2k.c 2011/01/07 15:47:14 1.53
+++ src/lib/libp2k/p2k.c 2011/01/07 16:02:32 1.54
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: p2k.c,v 1.53 2011/01/07 15:47:14 pooka Exp $ */ 1/* $NetBSD: p2k.c,v 1.54 2011/01/07 16:02:32 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2007, 2008, 2009 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2007, 2008, 2009 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by the 6 * Development of this software was supported by the
7 * Finnish Cultural Foundation. 7 * Finnish Cultural Foundation.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -334,30 +334,37 @@ p2k_init(uint32_t puffs_flags) @@ -334,30 +334,37 @@ p2k_init(uint32_t puffs_flags)
334 if (getenv("P2K_NODETACH") != NULL) { 334 if (getenv("P2K_NODETACH") != NULL) {
335 dodaemon = false; 335 dodaemon = false;
336 } 336 }
337 if (getenv("P2K_NOCACHE_PAGE") != NULL) { 337 if (getenv("P2K_NOCACHE_PAGE") != NULL) {
338 puffs_flags |= PUFFS_KFLAG_NOCACHE_PAGE; 338 puffs_flags |= PUFFS_KFLAG_NOCACHE_PAGE;
339 } 339 }
340 if (getenv("P2K_NOCACHE_NAME") != NULL) { 340 if (getenv("P2K_NOCACHE_NAME") != NULL) {
341 puffs_flags |= PUFFS_KFLAG_NOCACHE_NAME; 341 puffs_flags |= PUFFS_KFLAG_NOCACHE_NAME;
342 } 342 }
343 if (getenv("P2K_NOCACHE") != NULL) { 343 if (getenv("P2K_NOCACHE") != NULL) {
344 puffs_flags |= PUFFS_KFLAG_NOCACHE; 344 puffs_flags |= PUFFS_KFLAG_NOCACHE;
345 } 345 }
346 if ((envbuf = getenv("P2K_WIZARDUID")) != NULL) { 346 if ((envbuf = getenv("P2K_WIZARDUID")) != NULL) {
347 /* default to 0 in error cases */ 347 char *ep;
348 wizarduid = atoi(envbuf); 348
349 haswizard = 1; 349 wizarduid = strtoul(envbuf, &ep, 10);
350 printf("P2K WIZARD MODE: using uid %d\n", wizarduid); 350 if (envbuf[0] == '\0' || *ep != '\0') {
 351 printf("P2K_WIZARDUID: invalid uid %s\n", envbuf);
 352 } else if (wizarduid > UID_MAX) {
 353 printf("P2K_WIZARDUID: uid %s out-of-range\n", envbuf);
 354 } else {
 355 haswizard = 1;
 356 printf("P2K WIZARD MODE: using uid %d\n", wizarduid);
 357 }
351 } 358 }
352 359
353 p2m = allocp2m(); 360 p2m = allocp2m();
354 if (p2m == NULL) 361 if (p2m == NULL)
355 return NULL; 362 return NULL;
356 p2m->p2m_pu = puffs_init(pops, PUFFS_DEFER, PUFFS_DEFER, 363 p2m->p2m_pu = puffs_init(pops, PUFFS_DEFER, PUFFS_DEFER,
357 PUFFS_DEFER, puffs_flags); 364 PUFFS_DEFER, puffs_flags);
358 if (p2m->p2m_pu == NULL) { 365 if (p2m->p2m_pu == NULL) {
359 int sverrno = errno; 366 int sverrno = errno;
360 free(p2m); 367 free(p2m);
361 errno = sverrno; 368 errno = sverrno;
362 return NULL; 369 return NULL;
363 } 370 }