DD_Check.c
1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*=============================================================
*-------------------- 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);
}