Index: tmda-ofmipd
===================================================================
RCS file: /cvsroot/tmda/tmda/bin/tmda-ofmipd,v
retrieving revision 1.18
diff -u -r1.18 tmda-ofmipd
--- tmda-0.67/bin/tmda-ofmipd	21 Nov 2002 21:13:29 -0000	1.18
+++ tmda-0.67/bin/tmda-ofmipd	1 Jan 2003 06:45:40 -0000
@@ -42,6 +42,10 @@
     --debug
 	Turn on debugging prints.
 
+    -f
+    --foreground
+	Run in foreground.
+
     -u <username>
     --username <username>
 	The username that this program should run under.  The default
@@ -132,6 +136,7 @@
 program = sys.argv[0]
 configdir = None
 authprog = None
+foreground = None
 remoteauth = { 'proto': None,
                'host':  'localhost',
                'port':  None,
@@ -191,16 +196,17 @@
 
 try:
     opts, args = getopt.getopt(sys.argv[1:],
-                               'p:u:R:A:a:c:C:dVh', ['proxyport=',
-                                                     'username=',
-                                                     'authfile=',
-                                                     'remoteauth=',
-                                                     'authprog=',
-                                                     'configdir=',
-                                                     'connections=',
-                                                     'debug',
-                                                     'version',
-                                                     'help'])
+                               'p:u:R:A:a:c:C:dVhf', ['proxyport=',
+                                                      'username=',
+                                                      'authfile=',
+                                                      'remoteauth=',
+                                                      'authprog=',
+                                                      'configdir=',
+                                                      'connections=',
+                                                      'debug',
+                                                      'version',
+                                                      'help',
+                                                      'foreground'])
 except getopt.error, msg:
     usage(1, msg)
 
@@ -215,6 +221,8 @@
         sys.exit()
     elif opt in ('-d', '--debug'):
         DEBUGSTREAM = sys.stderr
+    elif opt in ('-f', '--foreground'):
+        foreground = 1
     elif opt in ('-p', '--proxyport'):
 	proxyport = arg
     elif opt in ('-u', '--username'):
@@ -1024,6 +1032,12 @@
         os.setgroups(Util.getgrouplist(username))
         # try seteuid()
         os.seteuid(pw_uid)
+
+    # Try to fork to go to daemon unless foreground mode
+    if foreground == None: 
+        if os.fork() != 0:
+            sys.exit()
+			
     # Start the event loop
     try:
         asyncore.loop()
