(file) Return to cimservera.c CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Security / Cimservera

Diff for /pegasus/src/Pegasus/Security/Cimservera/cimservera.c between version 1.1.2.2 and 1.6

version 1.1.2.2, 2007/01/04 06:58:32 version 1.6, 2008/04/04 23:40:42
Line 34 
Line 34 
 */ */
  
 #include <Executor/PAMAuth.h> #include <Executor/PAMAuth.h>
   #include <Executor/Socket.h>
   #include <Pegasus/Common/PegasusVersion.h>
 #include <stdio.h> #include <stdio.h>
 #include <stdlib.h> #include <stdlib.h>
 #include <syslog.h> #include <syslog.h>
Line 43 
Line 45 
  
 static void Exit(int status) static void Exit(int status)
 { {
     syslog(LOG_INFO, "exit(%d)", status);  
     exit(status);     exit(status);
 } }
  
 static ssize_t Recv(int sock, void* buffer, size_t size)  
 {  
     size_t r = size;  
     char* p = (char*)buffer;  
   
     if (size == 0)  
         return -1;  
   
     while (r)  
     {  
         ssize_t n;  
   
         EXECUTOR_RESTART(read(sock, p, r), n);  
   
         if (n == -1)  
             return -1;  
         else if (n == 0)  
             return size - r;  
   
         r -= n;  
         p += n;  
     }  
   
     return size - r;  
 }  
   
 int main(int argc, char* argv[]) int main(int argc, char* argv[])
 { {
     int sock;     int sock;
     CimserveraRequest request;     CimserveraRequest request;
       CimserveraResponse response;
  
     /* Open syslog: */     /* Open syslog: */
  
     openlog("cimservera", LOG_PID, LOG_AUTH);     openlog("cimservera", LOG_PID, LOG_AUTH);
     syslog(LOG_INFO, "started");  
  
     /* Check argumnents. */      /* Check arguments. */
  
     if (argc != 2)     if (argc != 2)
     {     {
Line 108 
Line 83 
  
     /* Wait on request. */     /* Wait on request. */
  
     if (Recv(sock, &request, sizeof(request)) != sizeof(request))      if (RecvBlock(sock, &request, sizeof(request)) != sizeof(request))
     {     {
         close(sock);         close(sock);
         Exit(1);         Exit(1);
     }     }
  
       /* Handle request (authenticate or validateUser) */
   
     if (strcmp(request.arg0, "authenticate") == 0)     if (strcmp(request.arg0, "authenticate") == 0)
     {     {
         int status = PAMAuthenticateInProcess(request.arg1, request.arg2);         int status = PAMAuthenticateInProcess(request.arg1, request.arg2);
  
         if (status != 0)          response.status = status;
   
           if (SendBlock(sock, &response, sizeof(response)) != sizeof(response))
         {         {
             syslog(LOG_WARNING, "PAM authentication failed on user \"%s\"",              close(sock);
                 request.arg1);              Exit(1);
         }         }
  
           close(sock);
         Exit(status == 0 ? 0 : 1);         Exit(status == 0 ? 0 : 1);
     }     }
     else if (strcmp(request.arg0, "validateUser") == 0)     else if (strcmp(request.arg0, "validateUser") == 0)
     {     {
         int status = PAMValidateUserInProcess(request.arg1);         int status = PAMValidateUserInProcess(request.arg1);
  
         if (status != 0)          response.status = status;
   
           if (SendBlock(sock, &response, sizeof(response)) != sizeof(response))
         {         {
             syslog(LOG_WARNING, "PAM user validation failed on user \"%s\"",              close(sock);
                 request.arg1);              Exit(1);
         }         }
  
           close(sock);
         Exit(status == 0 ? 0 : 1);         Exit(status == 0 ? 0 : 1);
     }     }
     else  
     {  
         syslog(LOG_WARNING, "invalid request");         syslog(LOG_WARNING, "invalid request");
         close(sock);         close(sock);
         Exit(1);         Exit(1);
     }      return 1;
   
     close(sock);  
     Exit(0);  
     return 0;  
 } }


Legend:
Removed from v.1.1.2.2  
changed lines
  Added in v.1.6

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2