(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.4

version 1.1.2.2, 2007/01/04 06:58:32 version 1.4, 2007/11/07 20:39:53
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);      syslog(LOG_DEBUG, "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");      syslog(LOG_DEBUG, "started");
  
     /* Check argumnents. */      /* Check arguments. */
  
     if (argc != 2)     if (argc != 2)
     {     {
Line 108 
Line 85 
  
     /* 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)         if (status != 0)
         {         {
             syslog(LOG_WARNING, "PAM authentication failed on user \"%s\"",              syslog(LOG_WARNING, "user \"%s\" failed to authenticate",
                 request.arg1);                 request.arg1);
         }         }
  
           response.status = status;
   
           if (SendBlock(sock, &response, sizeof(response)) != sizeof(response))
           {
               close(sock);
               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)
Line 132 
Line 120 
  
         if (status != 0)         if (status != 0)
         {         {
             syslog(LOG_WARNING, "PAM user validation failed on user \"%s\"",              syslog(LOG_WARNING, "failed to validate user \"%s\"", request.arg1);
                 request.arg1);  
         }         }
  
         Exit(status == 0 ? 0 : 1);          response.status = status;
     }  
     else          if (SendBlock(sock, &response, sizeof(response)) != sizeof(response))
     {     {
         syslog(LOG_WARNING, "invalid request");  
         close(sock);         close(sock);
         Exit(1);         Exit(1);
     }     }
  
     close(sock);     close(sock);
     Exit(0);          Exit(status == 0 ? 0 : 1);
     return 0;      }
   
       syslog(LOG_WARNING, "invalid request");
       close(sock);
       Exit(1);
       return 1;
 } }


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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2