chiark / gitweb /
@@ -1,3 +1,9 @@
[userv.git] / servexec.c
index c1614f0d9952aeacf71f763b6094658cbfb5b579..01353cdaab6c643b8fb09f93b1aa141793574b4e 100644 (file)
@@ -35,6 +35,7 @@
 #include "common.h"
 #include "daemon.h"
 #include "lib.h"
+#include "both.h"
 #include "version.h"
 
 static void NONRETURNING serv_syscallfail(const char *msg) {
@@ -58,11 +59,19 @@ void bisexec_parameter(const char *const *argv) {
   serv_checkstdoutexit();
 }
   
+void bisexec_help(const char *const *argv) {
+  const char *const *pp;
+  
+  fputs("recognised builtin services:\n",stdout);
+  for (pp= builtinservicehelpstrings; *pp; pp++) printf("  %s\n",*pp);
+  serv_checkstdoutexit();
+}
+  
 void bisexec_version(const char *const *argv) {
   const unsigned char *p;
   int i;
   
-  printf("uservd version " VERSION VEREXT "; copyright (C)1996-1997 Ian Jackson.\n"
+  printf("uservd version " VERSION VEREXT "; copyright (C)1996-2000 Ian Jackson.\n"
 #ifdef DEBUG
         "DEBUGGING VERSION"
 #else
@@ -129,6 +138,15 @@ void bisexec_execute(const char *const *argv) {
   serv_checkstdoutexit();
 }
 
+void bisexec_shutdown(const char *const *argv) {
+  /* This is only reached if the serviceuser_uid test in
+   * process.c:servicerequest() fails (we have to handle the
+   * shutdown request there, unfortunately).
+   */
+  fputs("uservd: builtin service shutdown: permission denied\n",stderr);
+  _exit(-1);
+}
+
 static void serv_resetsignal(int signo) {
   struct sigaction sig;
   
@@ -248,7 +266,8 @@ void execservice(const int synchsocket[], int clientfd) {
     fdarray[fd].holdfd= -1;
   }
   for (fd=0; fd<fdarrayused; fd++) {
-    if (fdarray[fd].realfd < fdarrayused) fdarray[fdarray[fd].realfd].holdfd= fd;
+    if (fdarray[fd].realfd < fdarrayused && fdarray[fd].realfd >= 0)
+      fdarray[fdarray[fd].realfd].holdfd= fd;
   }
   for (fd=0; fd<fdarrayused; fd++) {
     realfd= fdarray[fd].realfd;