summaryrefslogtreecommitdiff
path: root/src/tc-switchuser.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2023-11-21 09:56:26 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2023-11-21 09:56:26 +0100
commit987942a206ef0f2342bf81d5de6432c6af42b7e7 (patch)
tree6befd1ab8680f2936d94ac84c94cf4f68f16c14e /src/tc-switchuser.c
parent163bc6d7fc268bdb1c7cc03699f69d0c5cc0b4cd (diff)
New upstream version 4.17upstream/4.17
Diffstat (limited to 'src/tc-switchuser.c')
-rw-r--r--src/tc-switchuser.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/tc-switchuser.c b/src/tc-switchuser.c
index 1763527..4cc5604 100644
--- a/src/tc-switchuser.c
+++ b/src/tc-switchuser.c
@@ -19,7 +19,7 @@ static const struct HXoption options_table[] = {
HXOPT_TABLEEND,
};
-int main(int argc, const char **argv)
+static int runner(int argc, const char **argv)
{
HX_getopt(options_table, &argc, &argv, HXOPT_USAGEONERR);
const char *user = user_name != NULL ? user_name : "-";
@@ -27,12 +27,12 @@ int main(int argc, const char **argv)
switch (HXproc_switch_user(user_name, group_name)) {
case HXPROC_USER_NOT_FOUND:
if (user_name == NULL)
- abort(); /* impossible outcomes */
+ return EXIT_FAILURE; /* impossible outcomes */
printf("No such user \"%s\": %s\n", user_name, strerror(errno));
break;
case HXPROC_GROUP_NOT_FOUND:
if (group_name == NULL || *group_name == '\0')
- abort(); /* impossible outcome */
+ return EXIT_FAILURE; /* impossible outcome */
printf("No such group \"%s\": %s\n", group_name, strerror(errno));
break;
case HXPROC_SETUID_FAILED:
@@ -64,6 +64,14 @@ int main(int argc, const char **argv)
}
return EXIT_SUCCESS;
}
+
+int main(int argc, const char **argv)
+{
+ int ret = runner(argc, argv);
+ if (ret != EXIT_SUCCESS)
+ fprintf(stderr, "FAILED\n");
+ return ret;
+}
#else
int main(void)
{