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

  1 kumpf 1.2 /*
  2           //%2006////////////////////////////////////////////////////////////////////////
  3           //
  4           // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  5           // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  6           // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  7           // IBM Corp.; EMC Corporation, The Open Group.
  8           // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  9           // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 10           // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 11           // EMC Corporation; VERITAS Software Corporation; The Open Group.
 12           // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 13           // EMC Corporation; Symantec Corporation; The Open Group.
 14           //
 15           // Permission is hereby granted, free of charge, to any person obtaining a copy
 16           // of this software and associated documentation files (the "Software"), to
 17           // deal in the Software without restriction, including without limitation the
 18           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 19           // sell copies of the Software, and to permit persons to whom the Software is
 20           // furnished to do so, subject to the following conditions:
 21           // 
 22 kumpf 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 23           // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 24           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 25           // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 26           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 27           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 28           // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 29           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 30           //
 31           //==============================================================================
 32           //
 33           //%/////////////////////////////////////////////////////////////////////////////
 34           */
 35           
 36           #include <Executor/PAMAuth.h>
 37 kumpf 1.3 #include <Executor/Socket.h>
 38 kumpf 1.4 #include <Pegasus/Common/PegasusVersion.h>
 39 kumpf 1.2 #include <stdio.h>
 40           #include <stdlib.h>
 41           #include <syslog.h>
 42           #include <unistd.h>
 43           #include <errno.h>
 44           #include <string.h>
 45           
 46           static void Exit(int status)
 47           {
 48               exit(status);
 49           }
 50           
 51           int main(int argc, char* argv[])
 52           {
 53               int sock;
 54               CimserveraRequest request;
 55 kumpf 1.3     CimserveraResponse response;
 56 kumpf 1.2 
 57               /* Open syslog: */
 58           
 59               openlog("cimservera", LOG_PID, LOG_AUTH);
 60           
 61 kumpf 1.3     /* Check arguments. */
 62 kumpf 1.2 
 63               if (argc != 2)
 64               {
 65                   fprintf(stderr, "Usage: %s <socket-number>\n", argv[0]);
 66                   Exit(1);
 67               }
 68           
 69               /* Open socket stream. */
 70           
 71               {
 72                   char* end;
 73                   long x = strtoul(argv[1], &end, 10);
 74           
 75                   if (*end != '\0')
 76                   {
 77                       fprintf(stderr, "%s : bad socket argument: %s\n", argv[0], argv[1]);
 78                       Exit(1);
 79                   }
 80                   
 81                   sock = (int)x;
 82               }
 83 kumpf 1.2 
 84               /* Wait on request. */
 85           
 86 kumpf 1.3     if (RecvBlock(sock, &request, sizeof(request)) != sizeof(request))
 87 kumpf 1.2     {
 88                   close(sock);
 89                   Exit(1);
 90               }
 91           
 92               /* Handle request (authenticate or validateUser) */
 93           
 94               if (strcmp(request.arg0, "authenticate") == 0)
 95               {
 96                   int status = PAMAuthenticateInProcess(request.arg1, request.arg2);
 97           
 98 kumpf 1.3         response.status = status;
 99           
100                   if (SendBlock(sock, &response, sizeof(response)) != sizeof(response))
101                   {
102                       close(sock);
103                       Exit(1);
104                   }
105           
106                   close(sock);
107 kumpf 1.2         Exit(status == 0 ? 0 : 1);
108               }
109               else if (strcmp(request.arg0, "validateUser") == 0)
110               {
111                   int status = PAMValidateUserInProcess(request.arg1);
112           
113 kumpf 1.3         response.status = status;
114           
115                   if (SendBlock(sock, &response, sizeof(response)) != sizeof(response))
116                   {
117                       close(sock);
118                       Exit(1);
119                   }
120 kumpf 1.2 
121 kumpf 1.3         close(sock);
122 kumpf 1.2         Exit(status == 0 ? 0 : 1);
123               }
124           
125 kumpf 1.3     syslog(LOG_WARNING, "invalid request");
126 kumpf 1.2     close(sock);
127 kumpf 1.3     Exit(1);
128               return 1;
129 kumpf 1.2 }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2