[BACK] Return to cimservera.cpp CVS log [TXT][DIR] Up to [Pegasus] / pegasus / src / Pegasus / Security / Cimservera

Diff for /pegasus/src/Pegasus/Security/Cimservera/Attic/cimservera.cpp between version 1.6.30.3 and 1.6.30.4

version 1.6.30.3, 2006/12/31 22:14:51 version 1.6.30.4, 2006/12/31 23:03:58
Line 33 
Line 33 
  
 #include "cimservera.h" #include "cimservera.h"
 #include <cstdio> #include <cstdio>
  #include <syslog.h>
  
  static void Exit(int status)
  {
      if (status == 0)
          syslog(LOG_INFO, "exiting with status=%d", status);
      else
          syslog(LOG_WARNING, "exiting with status=%d", status);
  
      exit(status);
  }
  
 int main(int argc, char* argv[]) int main(int argc, char* argv[])
 { {
      // Open syslog:
  
      openlog("cimservera", 0, LOG_AUTH);
      syslog(LOG_INFO, "started");
  
      // ATTN: Insert fingerprint logic to detect running of this program as
      // non-child of executor.
  
     // Check argumnents.     // Check argumnents.
  
     if (argc != 2)     if (argc != 2)
     {     {
         fprintf(stderr, "Usage: %s <socket-number>\n", argv[0]);         fprintf(stderr, "Usage: %s <socket-number>\n", argv[0]);
         exit(1);         Exit(1);
     }     }
  
     // Open socket stream.     // Open socket stream.
Line 54 
Line 73 
         if (*end != '\0')         if (*end != '\0')
         {         {
             fprintf(stderr, "%s : bad socket argument: %s\n", argv[0], argv[1]);             fprintf(stderr, "%s : bad socket argument: %s\n", argv[0], argv[1]);
             exit(1);             Exit(1);
         }         }
                  
         sock = int(x);         sock = int(x);
Line 68 
Line 87 
     if (Recv(sock, &request, sizeof(request)) != sizeof(request))     if (Recv(sock, &request, sizeof(request)) != sizeof(request))
     {     {
         close(sock);         close(sock);
         return -1;         Exit(1);
     }     }
  
     if (strcmp(request.arg0, "authenticate") == 0)     if (strcmp(request.arg0, "authenticate") == 0)
     {     {
         int status = PAMAuthenticate(request.arg1, request.arg2);         int status = PAMAuthenticateInProcess(request.arg1, request.arg2);
  
          if (status != 0)
          {
              syslog(LOG_WARNING, "PAM authentication failed on user \"%s\"",
                  request.arg1);
          }
  
         Send(sock, &status, sizeof(status));         Send(sock, &status, sizeof(status));
     }     }
     else if (strcmp(request.arg0, "validateUser") == 0)     else if (strcmp(request.arg0, "validateUser") == 0)
     {     {
         int status = PAMValidateUser(request.arg1);         int status = PAMValidateUserInProcess(request.arg1);
  
          if (status != 0)
          {
              syslog(LOG_WARNING, "PAM user validation failed on user \"%s\"",
                  request.arg1);
          }
  
         Send(sock, &status, sizeof(status));         Send(sock, &status, sizeof(status));
     }     }
     else     else
     {     {
         fprintf(stderr, "%s: bad request\n", argv[0]);         syslog(LOG_WARNING, "invalid request");
         close(sock);         close(sock);
         exit(1);         Exit(1);
     }     }
  
     close(sock);     close(sock);
  
     exit(0);     Exit(0);
     return 0; 
 } }


Legend:
Removed from v.1.6.30.3 
changed lines
 Added in v.1.6.30.4