File: request.c

package info (click to toggle)
gidentd 0.4.5-7.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 296 kB
  • ctags: 57
  • sloc: ansic: 616; sh: 419; makefile: 51
file content (47 lines) | stat: -rw-r--r-- 714 bytes parent folder | download | duplicates (4)
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
42
43
44
45
46
47
#include "parse.h"
#include "socket.h"
#include "request.h"
#include "system.h"

Request_Struct req;

int Handle_Request(char *line)
{
	memset(&req, 0, sizeof(req));
	
	if(!line) return(-1);
	if(Parse_Request(line, &req.lp, &req.rp)) {
		Reply_Error("INVALID-PORT");
		return(-1);
	}
		
	switch(ipversion) {
	case 4:
		req.uid=tcp4();
		break;
	case 6:
		req.uid=tcp6();
		if(req.uid<0) req.uid=tcp4();
		break;
	default:
		req.uid=-1;
		break;
	}
	
	switch(req.uid) {
	case -1:
		Reply_Error("UNKNOWN-ERROR");
		break;
	case -2:
		Reply_Error("NO-USER");
		break;
	default:
		if(UserInfo(req.uid, &req.name, &req.home)) 
			Reply_Error("UNKNOWN-ERROR");
		else
			Reply_User(req.name);
		break;
	}
	return(0);
}