chiark
/
gitweb
/
~mdw
/
become
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
908a593
)
Small tweaks. Support no-network configuration option, and rearrange
author
mdw
<mdw>
Thu, 23 Apr 1998 13:21:04 +0000
(13:21 +0000)
committer
mdw
<mdw>
Thu, 23 Apr 1998 13:21:04 +0000
(13:21 +0000)
the help text a little.
src/become.c
patch
|
blob
|
blame
|
history
diff --git
a/src/become.c
b/src/become.c
index 2b8eedd2e598dfab85173364ad6b7c71c6f06435..67eec160860e857a0b23734712f76288f2bfbe50 100644
(file)
--- a/
src/become.c
+++ b/
src/become.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: become.c,v 1.1
5 1998/01/13 11:10:4
4 mdw Exp $
+ * $Id: become.c,v 1.1
6 1998/04/23 13:21:0
4 mdw Exp $
*
* Main code for `become'
*
*
* Main code for `become'
*
@@
-29,6
+29,10
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: become.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: become.c,v $
+ * Revision 1.16 1998/04/23 13:21:04 mdw
+ * Small tweaks. Support no-network configuration option, and rearrange
+ * the help text a little.
+ *
* Revision 1.15 1998/01/13 11:10:44 mdw
* Add `TZ' to the list of variables to be preserved.
*
* Revision 1.15 1998/01/13 11:10:44 mdw
* Add `TZ' to the list of variables to be preserved.
*
@@
-152,11
+156,9
@@
enum {
/* --- Login behaviour types --- */
/* --- Login behaviour types --- */
-enum {
- l_preserve, /* Preserve the environment */
- l_setuser, /* Update who I am */
- l_login /* Do a full login */
-};
+#define l_preserve 0 /* Preserve the environment */
+#define l_setuser 1 /* Update who I am */
+#define l_login 2 /* Do a full login */
/* --- Group behaviour types --- *
*
/* --- Group behaviour types --- *
*
@@
-370,7
+372,10
@@
static void bc__usage(FILE *fp)
"Usage: \n"
" $ -c <shell-command> <user>\n"
" $ [<env-var>] <user> [<command> [<arguments>]...]\n"
"Usage: \n"
" $ -c <shell-command> <user>\n"
" $ [<env-var>] <user> [<command> [<arguments>]...]\n"
- " $ -d [-p <port>] [-f <config-file>]\n");
+#ifndef NONETWORK
+ " $ -d [-p <port>] [-f <config-file>]\n"
+#endif
+ );
}
/* --- @bc__help@ --- *
}
/* --- @bc__help@ --- *
@@
-410,7
+415,17
@@
static void bc__help(FILE *fp, int suid)
"-e, --preserve-environment Try to preserve the current environment\n"
"-s, --su, --set-user Set environment variables to reflect USER\n"
"-l, --login Really log in as USER\n"
"-e, --preserve-environment Try to preserve the current environment\n"
"-s, --su, --set-user Set environment variables to reflect USER\n"
"-l, --login Really log in as USER\n"
-"\n"
+" [Default is "
+#if DEFAULT_LOGIN_STYLE == l_preserve
+ "preserve-environment"
+#elif DEFAULT_LOGIN_STYLE == l_setuser
+ "set-user"
+#elif DEFAULT_LOGIN_STYLE == l_login
+ "login"
+#else
+ "poorly configured"
+#endif
+"]\n\n"
"-g GROUP, --group=GROUP Set primary group-id to be GROUP\n"
#ifdef HAVE_SETGROUPS
"-k, --keep-groups Keep your current set of groups\n"
"-g GROUP, --group=GROUP Set primary group-id to be GROUP\n"
#ifdef HAVE_SETGROUPS
"-k, --keep-groups Keep your current set of groups\n"
@@
-419,10
+434,13
@@
static void bc__help(FILE *fp, int suid)
#endif
"\n"
"-c CMD, --command=CMD Run the (Bourne) shell command CMD\n"
#endif
"\n"
"-c CMD, --command=CMD Run the (Bourne) shell command CMD\n"
+#ifndef NONETWORK
"\n"
"-d, --daemon Start a daemon\n"
"-p PORT, --port=PORT In daemon mode, listen on PORT\n"
"\n"
"-d, --daemon Start a daemon\n"
"-p PORT, --port=PORT In daemon mode, listen on PORT\n"
-"-f FILE, --config-file=FILE In daemon mode, read config from FILE\n");
+"-f FILE, --config-file=FILE In daemon mode, read config from FILE\n"
+#endif
+ );
#ifdef TRACING
bc__write(fp, "\n");
if (!suid) {
#ifdef TRACING
bc__write(fp, "\n");
if (!suid) {
@@
-460,8
+478,10
@@
int main(int argc, char *argv[])
/* --- Become server setup parameters --- */
/* --- Become server setup parameters --- */
+#ifndef NONETWORK
char *conffile = file_RULES; /* Default config file for daemon */
int port = 0; /* Default port for daemon */
char *conffile = file_RULES; /* Default config file for daemon */
int port = 0; /* Default port for daemon */
+#endif
/* --- Miscellanous shared variables --- */
/* --- Miscellanous shared variables --- */
@@
-546,9
+566,11
@@
int main(int argc, char *argv[])
/* --- Server options --- */
/* --- Server options --- */
+#ifndef NONETWORK
{ "daemon", 0, 0, 'd' },
{ "port", gFlag_argReq, 0, 'p' },
{ "config-file", gFlag_argReq, 0, 'f' },
{ "daemon", 0, 0, 'd' },
{ "port", gFlag_argReq, 0, 'p' },
{ "config-file", gFlag_argReq, 0, 'f' },
+#endif
/* --- Tracing options --- */
/* --- Tracing options --- */
@@
-571,7
+593,9
@@
int main(int argc, char *argv[])
"g:" /* Group (without @setgroups@) */
#endif
"c:" /* Command to run options */
"g:" /* Group (without @setgroups@) */
#endif
"c:" /* Command to run options */
+#ifndef NONETWORK
"dp:f:" /* Server options */
"dp:f:" /* Server options */
+#endif
#ifdef TRACING
"I:T::L::" /* Tracing options */
#endif
#ifdef TRACING
"I:T::L::" /* Tracing options */
#endif
@@
-641,6
+665,7
@@
int main(int argc, char *argv[])
/* --- Server options --- */
/* --- Server options --- */
+#ifndef NONETWORK
case 'p':
if (isdigit((unsigned char)optarg[0]))
port = htons(atoi(optarg));
case 'p':
if (isdigit((unsigned char)optarg[0]))
port = htons(atoi(optarg));
@@
-657,6
+682,7
@@
int main(int argc, char *argv[])
case 'f':
conffile = optarg;
break;
case 'f':
conffile = optarg;
break;
+#endif
/* --- Pretend to be a different user --- *
*
/* --- Pretend to be a different user --- *
*
@@
-749,12
+775,14
@@
int main(int argc, char *argv[])
static tr lvltbl[] = {
{ 'm', TRACE_MISC, "miscellaneous messages" },
{ 's', TRACE_SETUP, "building the request block" },
static tr lvltbl[] = {
{ 'm', TRACE_MISC, "miscellaneous messages" },
{ 's', TRACE_SETUP, "building the request block" },
- { 'd', TRACE_DAEMON, "server process" },
{ 'r', TRACE_RULE, "ruleset scanning" },
{ 'c', TRACE_CHECK, "request checking" },
{ 'r', TRACE_RULE, "ruleset scanning" },
{ 'c', TRACE_CHECK, "request checking" },
+#ifndef NONETWORK
+ { 'd', TRACE_DAEMON, "server process" },
{ 'l', TRACE_CLIENT, "client process" },
{ 'R', TRACE_RAND, "random number generator" },
{ 'C', TRACE_CRYPTO, "cryptographic processing of requests" },
{ 'l', TRACE_CLIENT, "client process" },
{ 'R', TRACE_RAND, "random number generator" },
{ 'C', TRACE_CRYPTO, "cryptographic processing of requests" },
+#endif
{ 'y', TRACE_YACC, "parsing configuration file" },
{ 'D', TRACE_DFL, "default tracing options" },
{ 'A', TRACE_ALL, "all tracing options" },
{ 'y', TRACE_YACC, "parsing configuration file" },
{ 'D', TRACE_DFL, "default tracing options" },
{ 'A', TRACE_ALL, "all tracing options" },
@@
-872,11
+900,13
@@
done_options:
/* --- Switch to daemon mode if requested --- */
/* --- Switch to daemon mode if requested --- */
+#ifndef NONETWORK
if (flags & f_daemon) {
T( trace(TRACE_MISC, "become: daemon mode requested"); )
daemon_init(conffile, port);
exit(0);
}
if (flags & f_daemon) {
T( trace(TRACE_MISC, "become: daemon mode requested"); )
daemon_init(conffile, port);
exit(0);
}
+#endif
/* --- Open a syslog --- */
/* --- Open a syslog --- */
@@
-1029,7
+1059,7
@@
done_options:
ngroups = 0;
(void)(bc__addGroups(groups, &ngroups, ga, i) ||
((gstyle & g_keep) &&
ngroups = 0;
(void)(bc__addGroups(groups, &ngroups, ga, i) ||
((gstyle & g_keep) &&
- bc__addGroups(groups, &ngroups, from_gr,n_fgr)) ||
+ bc__addGroups(groups, &ngroups, from_gr,
n_fgr)) ||
((gstyle & g_replace) &&
bc__addGroups(groups, &ngroups, to_gr, n_tgr)));
}
((gstyle & g_replace) &&
bc__addGroups(groups, &ngroups, to_gr, n_tgr)));
}
@@
-1481,7
+1511,9
@@
done_options:
/* --- If this was a login, change current directory --- */
/* --- If this was a login, change current directory --- */
- if (flags & f_shell && style == l_login && chdir(to_pw->pw_dir) < 0) {
+ if ((flags & f_shell) &&
+ style == l_login &&
+ chdir(to_pw->pw_dir) < 0) {
moan("couldn't change directory to `%s': %s",
to_pw->pw_dir, strerror(errno));
}
moan("couldn't change directory to `%s': %s",
to_pw->pw_dir, strerror(errno));
}