summaryrefslogtreecommitdiffstats
path: root/usr.sbin/jail
diff options
context:
space:
mode:
authormaxim <maxim@FreeBSD.org>2003-04-02 09:20:08 +0000
committermaxim <maxim@FreeBSD.org>2003-04-02 09:20:08 +0000
commit9ab2ed3bdb796432bbf29e91a81e256908605657 (patch)
treef0f8449f8feb97c9c9f613b676ff63dd5803fe43 /usr.sbin/jail
parent6a2f46d4e86c43a17259941bd80a893d4440b73b (diff)
downloadFreeBSD-src-9ab2ed3bdb796432bbf29e91a81e256908605657.zip
FreeBSD-src-9ab2ed3bdb796432bbf29e91a81e256908605657.tar.gz
o Fix error messages formatting, style.
Prodded by: bde Reviewed by: bde
Diffstat (limited to 'usr.sbin/jail')
-rw-r--r--usr.sbin/jail/jail.c51
1 files changed, 22 insertions, 29 deletions
diff --git a/usr.sbin/jail/jail.c b/usr.sbin/jail/jail.c
index 7be0b4e..2040ff7 100644
--- a/usr.sbin/jail/jail.c
+++ b/usr.sbin/jail/jail.c
@@ -34,7 +34,7 @@ main(int argc, char **argv)
struct jail j;
struct passwd *pwd;
struct in_addr in;
- int ch, groups[NGROUPS], i, ngroups;
+ int ch, groups[NGROUPS], ngroups;
char *username;
username = NULL;
@@ -56,44 +56,36 @@ main(int argc, char **argv)
if (username != NULL) {
pwd = getpwnam(username);
if (pwd == NULL)
- err(1, "getpwnam %s", username);
+ err(1, "getpwnam: %s", username);
lcap = login_getpwclass(pwd);
if (lcap == NULL)
- err(1, "getpwclass failed", username);
+ err(1, "getpwclass: %s", username);
ngroups = NGROUPS;
- i = getgrouplist(username, pwd->pw_gid, groups, &ngroups);
- if (i)
- err(1, "getgrouplist %s", username);
+ if (getgrouplist(username, pwd->pw_gid, groups, &ngroups) != 0)
+ err(1, "getgrouplist: %s", username);
}
- i = chdir(argv[0]);
- if (i)
- err(1, "chdir %s", argv[0]);
+ if (chdir(argv[0]) != 0)
+ err(1, "chdir: %s", argv[0]);
memset(&j, 0, sizeof(j));
j.version = 0;
j.path = argv[0];
j.hostname = argv[1];
- i = inet_aton(argv[2], &in);
- if (!i)
- errx(1, "Couldn't make sense of ip-number\n");
+ if (inet_aton(argv[2], &in) == 0)
+ errx(1, "Could not make sense of ip-number: %s", argv[2]);
j.ip_number = ntohl(in.s_addr);
- i = jail(&j);
- if (i)
- err(1, "Imprisonment failed");
+ if (jail(&j) != 0)
+ err(1, "jail");
if (username != NULL) {
- i = setgroups(ngroups, groups);
- if (i)
- err(1, "setgroups failed");
- i = setgid(pwd->pw_gid);
- if (i)
- err(1, "setgid failed");
- i = setusercontext(lcap, pwd, pwd->pw_uid,
- LOGIN_SETALL & ~LOGIN_SETGROUP);
- if (i)
- err(1, "setusercontext failed");
+ if (setgroups(ngroups, groups) != 0)
+ err(1, "setgroups");
+ if (setgid(pwd->pw_gid) != 0)
+ err(1, "setgid");
+ if (setusercontext(lcap, pwd, pwd->pw_uid,
+ LOGIN_SETALL & ~LOGIN_SETGROUP) != 0)
+ err(1, "setusercontext");
}
- i = execv(argv[3], argv + 3);
- if (i)
- err(1, "execv(%s)", argv[3]);
+ if (execv(argv[3], argv + 3) != 0)
+ err(1, "execv: %s", argv[3]);
exit (0);
}
@@ -101,6 +93,7 @@ static void
usage(void)
{
- errx(1,
+ (void)fprintf(stderr, "%s\n",
"Usage: jail [-u username] path hostname ip-number command ...");
+ exit(1);
}
OpenPOWER on IntegriCloud