Running the samba daemons under daemontools?
Jos Backus
josb at cncdsl.com
Mon Apr 23 00:55:21 GMT 2001
Are there any plans to make it possible to run {n,s}mbd under Dan Bernstein's
daemontools package? (see http://cr.yp.to/daemontools.html for details) This
would require adding a new flag wich tells {n,s}mdb not to background
themselves but still listen for connections.
Here's a patch:
diff -ru samba-2.2.0.dist/source/nmbd/nmbd.c samba-2.2.0/source/nmbd/nmbd.c
--- samba-2.2.0.dist/source/nmbd/nmbd.c Sun Apr 8 13:22:30 2001
+++ samba-2.2.0/source/nmbd/nmbd.c Sun Apr 22 17:49:20 2001
@@ -46,6 +46,9 @@
/* are we running as a daemon ? */
static BOOL is_daemon = False;
+/* run in foreground */
+static BOOL in_foreground = False;
+
/* have we found LanMan clients yet? */
BOOL found_lm_clients = False;
@@ -632,6 +635,7 @@
printf( "Usage: %s [-DaohV] [-H lmhosts file] [-d debuglevel] [-l log basename]\n", pname );
printf( " [-n name] [-p port] [-s configuration file]\n" );
printf( "\t-D Become a daemon\n" );
+ printf( "\t-F Execute in foreground\n" );
printf( "\t-a Append to log file (default)\n" );
printf( "\t-o Overwrite log file, don't append\n" );
printf( "\t-h Print usage\n" );
@@ -706,7 +710,7 @@
#endif
while( EOF !=
- (opt = getopt( argc, argv, "Vaos:T:I:C:bAB:N:Rn:l:d:Dp:hSH:G:f:" )) )
+ (opt = getopt( argc, argv, "Vaos:T:I:C:bAB:N:Rn:l:d:Dp:hSH:G:f:F" )) )
{
switch (opt)
{
@@ -739,6 +743,9 @@
case 'D':
is_daemon = True;
break;
+ case 'F':
+ in_foreground = True;
+ break;
case 'd':
DEBUGLEVEL = atoi(optarg);
break;
@@ -795,7 +802,7 @@
is_daemon = True;
}
- if (is_daemon)
+ if (!in_foreground && is_daemon)
{
DEBUG( 2, ( "Becoming a daemon.\n" ) );
become_daemon();
diff -ru samba-2.2.0.dist/source/smbd/server.c samba-2.2.0/source/smbd/server.c
--- samba-2.2.0.dist/source/smbd/server.c Sun Apr 8 23:35:52 2001
+++ samba-2.2.0/source/smbd/server.c Sun Apr 22 17:44:40 2001
@@ -515,6 +515,7 @@
printf("Usage: %s [-DaoPh?V] [-d debuglevel] [-l log basename] [-p port]\n", pname);
printf(" [-O socket options] [-s services file]\n");
printf("\t-D Become a daemon\n");
+ printf("\t-F Execute in foreground\n");
printf("\t-a Append to log file (default)\n");
printf("\t-o Overwrite log file, don't append\n");
printf("\t-h Print usage\n");
@@ -537,6 +538,7 @@
extern BOOL append_log;
/* shall I run as a daemon */
BOOL is_daemon = False;
+ BOOL in_foreground = False;
BOOL specified_logfile = False;
int port = SMB_PORT;
int opt;
@@ -552,7 +554,7 @@
argc--;
}
- while ( EOF != (opt = getopt(argc, argv, "O:l:s:d:Dp:h?Vaof:")) )
+ while ( EOF != (opt = getopt(argc, argv, "O:l:s:d:Dp:h?Vaof:F")) )
switch (opt) {
case 'O':
pstrcpy(user_socket_options,optarg);
@@ -579,6 +581,10 @@
is_daemon = True;
break;
+ case 'F':
+ in_foreground = True;
+ break;
+
case 'd':
if (*optarg == 'A')
DEBUGLEVEL = 10000;
@@ -723,7 +729,7 @@
is_daemon = True;
}
- if (is_daemon) {
+ if (!in_foreground && is_daemon) {
DEBUG( 3, ( "Becoming a daemon.\n" ) );
become_daemon();
}
Thanks,
--
Jos Backus _/ _/_/_/ "Modularity is not a hack."
_/ _/ _/ -- D. J. Bernstein
_/ _/_/_/
_/ _/ _/ _/
josb at cncdsl.com _/_/ _/_/_/ use Std::Disclaimer;
More information about the samba-technical
mailing list