*/
#ifndef lint
-static char rcsid[] = "$Id: auth.c,v 1.36 1998/03/25 01:26:03 paulus Exp $";
+static char rcsid[] = "$Id: auth.c,v 1.37 1998/03/26 04:46:03 paulus Exp $";
#endif
#include <stdio.h>
*/
if (maxconnect > 0)
TIMEOUT(connect_time_expired, 0, maxconnect);
+
+ /*
+ * Detach now, if the updetach option was given.
+ */
+ if (nodetach == -1)
+ detach();
}
++num_np_up;
}
*/
#ifndef lint
-static char rcsid[] = "$Id: main.c,v 1.45 1998/03/25 01:28:14 paulus Exp $";
+static char rcsid[] = "$Id: main.c,v 1.46 1998/03/26 04:46:04 paulus Exp $";
#endif
#include <stdio.h>
int hungup; /* terminal has been hung up */
int privileged; /* we're running as real uid root */
int need_holdoff; /* need holdoff period before restarting */
+int detached; /* have detached from terminal */
int phase; /* where the link is at */
int kill_link;
int open_ccp_flag;
-int redirect_stderr; /* Connector's stderr should go to file */
char **script_env; /* Env. variable values for scripts */
int s_env_nalloc; /* # words avail at script_env */
*/
if (!default_device && strcmp(devnam, default_devnam) == 0)
default_device = 1;
- redirect_stderr = !nodetach || default_device;
+ if (default_device)
+ nodetach = 1;
/*
* Initialize system-dependent stuff and magic number package.
* Detach ourselves from the terminal, if required,
* and identify who is running us.
*/
- if (!default_device && !nodetach && daemon(0, 0) < 0) {
- perror("Couldn't detach from controlling terminal");
- exit(1);
- }
+ if (nodetach == 0)
+ detach();
pid = getpid();
p = getlogin();
if (p == NULL) {
return 0;
}
+/*
+ * detach - detach us from the controlling terminal.
+ */
+void
+detach()
+{
+ if (detached)
+ return;
+ if (daemon(0, 0) < 0) {
+ perror("Couldn't detach from controlling terminal");
+ die(1);
+ }
+ detached = 1;
+}
+
/*
* holdoff_end - called via a timeout when the holdoff period ends.
*/
close(out);
}
}
- if (redirect_stderr) {
+ if (nodetach == 0) {
close(2);
errfd = open(_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0600);
if (errfd >= 0 && errfd != 2) {
*/
#ifndef lint
-static char rcsid[] = "$Id: options.c,v 1.41 1998/03/25 01:29:05 paulus Exp $";
+static char rcsid[] = "$Id: options.c,v 1.42 1998/03/26 04:46:06 paulus Exp $";
#endif
#include <ctype.h>
static int setnocrtscts __P((char **));
static int setxonxoff __P((char **));
static int setnodetach __P((char **));
+static int setupdetach __P((char **));
static int setmodem __P((char **));
static int setlocal __P((char **));
static int setlock __P((char **));
{"-d", 0, setdebug}, /* Increase debugging level */
{"nodetach", 0, setnodetach}, /* Don't detach from controlling tty */
{"-detach", 0, setnodetach}, /* don't fork */
+ {"updetach", 0, setupdetach}, /* Detach once an NP has come up */
{"noip", 0, noip}, /* Disable IP and IPCP */
{"-ip", 0, noip}, /* Disable IP and IPCP */
{"nomagic", 0, nomagicnumber}, /* Disable magic number negotiation */
return (1);
}
+static int
+setupdetach(argv)
+ char **argv;
+{
+ nodetach = -1;
+ return (1);
+}
+
static int
setdemand(argv)
char **argv;
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: pppd.h,v 1.20 1998/03/25 01:30:18 paulus Exp $
+ * $Id: pppd.h,v 1.21 1998/03/26 04:46:08 paulus Exp $
*/
/*
extern int privileged; /* We were run by real-uid root */
extern int need_holdoff; /* Need holdoff period after link terminates */
extern char **script_env; /* Environment variables for scripts */
+extern int detached; /* Have detached from controlling tty */
/*
* Variables set by command-line options.
*/
/* Procedures exported from main.c. */
+void detach __P((void)); /* Detach from controlling tty */
void die __P((int)); /* Cleanup and exit */
void quit __P((void)); /* like die(1) */
void novm __P((char *)); /* Say we ran out of memory, and die */