ReactOS 0.4.15-dev-7704-gc07eb9f
netname.c File Reference
#include <wintirpc.h>
#include <rpc/rpc.h>
#include "rpc_com.h"
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for netname.c:

Go to the source code of this file.

Macros

#define MAXHOSTNAMELEN   256
 
#define NGROUPS   16
 
#define TYPE_BIT(type)   (sizeof (type) * CHAR_BIT)
 
#define TYPE_SIGNED(type)   (((type) -1) < 0)
 
#define INT_STRLEN_MAXIMUM(type)    ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
 

Functions

int getnetname (name)
 
int user2netname (netname, const uid_t uid, const char *domain)
 
int host2netname (netname, const char *host, const char *domain)
 

Variables

static charOPSYS = "unix"
 

Macro Definition Documentation

◆ INT_STRLEN_MAXIMUM

#define INT_STRLEN_MAXIMUM (   type)     ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))

Definition at line 69 of file netname.c.

◆ MAXHOSTNAMELEN

#define MAXHOSTNAMELEN   256

Definition at line 53 of file netname.c.

◆ NGROUPS

#define NGROUPS   16

Definition at line 56 of file netname.c.

◆ TYPE_BIT

#define TYPE_BIT (   type)    (sizeof (type) * CHAR_BIT)

Definition at line 59 of file netname.c.

◆ TYPE_SIGNED

#define TYPE_SIGNED (   type)    (((type) -1) < 0)

Definition at line 61 of file netname.c.

Function Documentation

◆ getnetname()

int getnetname ( name  )

Definition at line 78 of file netname.c.

80{
81#ifdef _WIN32
82 /* I don't understand what these underlying routines are accomplishing??? */
83 return 1;
84#else
85 uid_t uid;
86
87 uid = geteuid();
88 if (uid == 0) {
89 return (host2netname(name, (char *) NULL, (char *) NULL));
90 } else {
91 return (user2netname(name, uid, (char *) NULL));
92 }
93#endif
94}
long uid_t
Definition: various.h:8
#define NULL
Definition: types.h:112
int user2netname(netname, const uid_t uid, const char *domain)
Definition: netname.c:101
int host2netname(netname, const char *host, const char *domain)
Definition: netname.c:126
Definition: name.c:39
EXPORT uid_t geteuid()
Definition: uid.c:37

Referenced by authdes_pk_seccreate().

◆ host2netname()

int host2netname ( netname  ,
const char host,
const char domain 
)

Definition at line 126 of file netname.c.

130{
131 char *dfltdom;
132 char hostname[MAXHOSTNAMELEN+1];
133
134 if (domain == NULL) {
135 if (__rpc_get_default_domain(&dfltdom) != 0) {
136 return (0);
137 }
138 domain = dfltdom;
139 }
140 if (host == NULL) {
141 (void) gethostname(hostname, sizeof(hostname));
142 host = hostname;
143 }
144 if (strlen(domain) + 1 + strlen(host) + 1 + strlen(OPSYS) > MAXNETNAMELEN) {
145 return (0);
146 }
147 (void) sprintf(netname, "%s.%s@%s", OPSYS, host, domain);
148 return (1);
149}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * hostname
Definition: ftp.c:88
#define MAXNETNAMELEN
Definition: auth.h:78
INT WSAAPI gethostname(OUT char FAR *name, IN INT namelen)
Definition: getxbyxx.c:397
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static char * OPSYS
Definition: netname.c:72
#define MAXHOSTNAMELEN
Definition: netname.c:53
int __rpc_get_default_domain(char **)
Definition: rpcdname.c:72
Definition: cookie.c:42
char * host
Definition: whois.c:55

Referenced by getnetname().

◆ user2netname()

int user2netname ( netname  ,
const uid_t  uid,
const char domain 
)

Definition at line 101 of file netname.c.

105{
106 char *dfltdom;
107
108 if (domain == NULL) {
109 if (__rpc_get_default_domain(&dfltdom) != 0) {
110 return (0);
111 }
112 domain = dfltdom;
113 }
115 return (0);
116 }
117 (void) sprintf(netname, "%s.%ld@%s", OPSYS, (u_long)uid, domain);
118 return (1);
119}
unsigned long u_long
Definition: linux.h:269
#define INT_STRLEN_MAXIMUM(type)
Definition: netname.c:69

Referenced by getnetname().

Variable Documentation

◆ OPSYS

char* OPSYS = "unix"
static

Definition at line 72 of file netname.c.

Referenced by host2netname(), and user2netname().