summaryrefslogtreecommitdiff
path: root/src/daemontools-extras/s6-applyuidgid.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-03-12 11:59:43 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-03-12 11:59:43 +0000
commitc60ebd422171808ad58b936914055397bb205bef (patch)
tree7db3e5728d72ad209f8e22b9eb9f337e0b0c3e58 /src/daemontools-extras/s6-applyuidgid.c
parente28fe5908a91d8795ca9923d64eeed7d3e898434 (diff)
downloads6-c60ebd422171808ad58b936914055397bb205bef.tar.xz
Adapt to skalibs-2.5.0.0
Diffstat (limited to 'src/daemontools-extras/s6-applyuidgid.c')
-rw-r--r--src/daemontools-extras/s6-applyuidgid.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/daemontools-extras/s6-applyuidgid.c b/src/daemontools-extras/s6-applyuidgid.c
index b80564f..a770b2a 100644
--- a/src/daemontools-extras/s6-applyuidgid.c
+++ b/src/daemontools-extras/s6-applyuidgid.c
@@ -1,12 +1,10 @@
/* ISC license. */
#include <skalibs/nonposix.h>
-#include <sys/types.h>
#include <unistd.h>
#include <grp.h>
#include <limits.h>
-#include <skalibs/uint64.h>
-#include <skalibs/gidstuff.h>
+#include <skalibs/types.h>
#include <skalibs/setgroups.h>
#include <skalibs/strerr2.h>
#include <skalibs/sgetopt.h>
@@ -18,29 +16,29 @@
int main (int argc, char const *const *argv, char const *const *envp)
{
- uint64 uid = 0 ;
+ uid_t uid = 0 ;
gid_t gid = 0 ;
gid_t gids[NGROUPS_MAX] ;
- unsigned int gidn = (unsigned int)-1 ;
+ size_t gidn = (size_t)-1 ;
int unexport = 0 ;
PROG = "s6-applyuidgid" ;
{
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
- register int opt = subgetopt_r(argc, argv, "zUu:g:G:", &l) ;
+ int opt = subgetopt_r(argc, argv, "zUu:g:G:", &l) ;
if (opt == -1) break ;
switch (opt)
{
case 'z' : unexport = 1 ; break ;
- case 'u' : if (!uint640_scan(l.arg, &uid)) dieusage() ; break ;
+ case 'u' : if (!uid0_scan(l.arg, &uid)) dieusage() ; break ;
case 'g' : if (!gid0_scan(l.arg, &gid)) dieusage() ; break ;
case 'G' : if (!gid_scanlist(gids, NGROUPS_MAX, l.arg, &gidn) && *l.arg) dieusage() ; break ;
case 'U' :
{
char const *x = env_get2(envp, "UID") ;
if (!x) strerr_dienotset(100, "UID") ;
- if (!uint640_scan(x, &uid)) strerr_dieinvalid(100, "UID") ;
+ if (!uid0_scan(x, &uid)) strerr_dieinvalid(100, "UID") ;
x = env_get2(envp, "GID") ;
if (!x) strerr_dienotset(100, "GID") ;
if (!gid0_scan(x, &gid)) strerr_dieinvalid(100, "GID") ;
@@ -57,12 +55,11 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
if (!argc) dieusage() ;
- if (uid > (uint64)(uid_t)-1) strerr_dief1x(100, "uid value too big") ;
- if (gidn != (unsigned int)-1 && setgroups(gidn, gids) < 0)
+ if (gidn != (size_t)-1 && setgroups(gidn, gids) < 0)
strerr_diefu1sys(111, "set supplementary group list") ;
if (gid && setgid(gid) < 0)
strerr_diefu1sys(111, "setgid") ;
- if (uid && setuid((uid_t)uid) < 0)
+ if (uid && setuid(uid) < 0)
strerr_diefu1sys(111, "setuid") ;
if (unexport) pathexec_r(argv, envp, env_len(envp), "UID\0GID\0GIDLIST", 16) ;