DD_Check.c 1.13 KB
/*=============================================================
 *-------------------- DD_CHECK -------------------------------
 *                       V2.0
 * name:         DD_check.c
 * author:       Alexandr Grigoriev, Andrei Fedorov
 * date :              Oct 30 2002
 *
 * Description: Check for the current permission to work
 *              Uses with WEB interface
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <DD_Access.h>

main (int argc, char *argv[])
/*
 * LocalID - the Unix ID if user, invoking this program
 * LogName - the DD login name for specific user
 * HostName - current local host (in 255.255.255.255 form)
 */
{
   int length;
   char LogName[USRLENGTH],HostName[MAXHOSTLENGTH];
   int LocalID;
   
   LocalID=getuid();
   
   if((argc == 3))
   {
      if((length = strlen(argv[2])) >= USRLENGTH) length = USRLENGTH-1;
      strncpy(LogName,argv[2],length); LogName[length] = '\0';
      if((length = strlen(argv[1])) >= MAXHOSTLENGTH) length = MAXHOSTLENGTH-1;
      strncpy(HostName,argv[1],length); HostName[length] = '\0';
   }
   else return 2;

   return SetUser(LocalID,HostName,LogName);

}