ReactOS 0.4.15-dev-7788-g1ad9096
getpublickey.c File Reference
#include <wintirpc.h>
#include <stdio.h>
#include <rpc/rpc.h>
#include <rpc/key_prot.h>
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
#include <string.h>
#include <stdlib.h>
Include dependency graph for getpublickey.c:

Go to the source code of this file.

Macros

#define PKFILE   "/etc/publickey"
 

Functions

int __getpublickey_real (char *netname, char *publickey)
 
int getpublicandprivatekey (char *key, char *ret)
 
int getpublickey (char *netname, char *publickey) const
 

Variables

int(* __getpublickey_LOCAL )()=0
 

Macro Definition Documentation

◆ PKFILE

#define PKFILE   "/etc/publickey"

Definition at line 51 of file getpublickey.c.

Function Documentation

◆ __getpublickey_real()

int __getpublickey_real ( char netname,
char publickey 
)

Definition at line 62 of file getpublickey.c.

65{
66 char lookup[3 * HEXKEYBYTES];
67 char *p;
68
69 if (publickey == NULL)
70 return (0);
71 if (!getpublicandprivatekey(netname, lookup))
72 return (0);
73 p = strchr(lookup, ':');
74 if (p == NULL) {
75 return (0);
76 }
77 *p = '\0';
78 (void) strncpy(publickey, lookup, HEXKEYBYTES);
79 publickey[HEXKEYBYTES] = '\0';
80 return (1);
81}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define NULL
Definition: types.h:112
static ULONG lookup[16]
Definition: vga.c:38
int getpublicandprivatekey(char *key, char *ret)
Definition: getpublickey.c:89
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by getpublickey().

◆ getpublicandprivatekey()

int getpublicandprivatekey ( char key,
char ret 
)

Definition at line 89 of file getpublickey.c.

92{
93 char buf[1024]; /* big enough */
94 char *res;
95 FILE *fd;
96 char *mkey;
97 char *mval;
98
99 fd = fopen(PKFILE, "r");
100 if (fd == NULL)
101 return (0);
102 for (;;) {
103 res = fgets(buf, sizeof(buf), fd);
104 if (res == NULL) {
105 fclose(fd);
106 return (0);
107 }
108 if (res[0] == '#')
109 continue;
110 else if (res[0] == '+') {
111#ifdef YP
112 char *PKMAP = "publickey.byname";
113 char *lookup;
114 char *domain;
115 int err;
116 int len;
117
118 err = yp_get_default_domain(&domain);
119 if (err) {
120 continue;
121 }
122 lookup = NULL;
123 err = yp_match(domain, PKMAP, key, strlen(key), &lookup, &len);
124 if (err) {
125#ifdef DEBUG
126 fprintf(stderr, "match failed error %d\n", err);
127#endif
128 continue;
129 }
130 lookup[len] = 0;
131 strcpy(ret, lookup);
132 fclose(fd);
133 free(lookup);
134 return (2);
135#else /* YP */
136#ifdef DEBUG
138"Bad record in %s '+' -- NIS not supported in this library copy\n", PKFILE);
139#endif /* DEBUG */
140 continue;
141#endif /* YP */
142 } else {
143 mkey = strsep(&res, "\t ");
144 if (mkey == NULL) {
146 "Bad record in %s -- %s", PKFILE, buf);
147 continue;
148 }
149 do {
150 mval = strsep(&res, " \t#\n");
151 } while (mval != NULL && !*mval);
152 if (mval == NULL) {
154 "Bad record in %s val problem - %s", PKFILE, buf);
155 continue;
156 }
157 if (strcmp(mkey, key) == 0) {
158 strcpy(ret, mval);
159 fclose(fd);
160 return (1);
161 }
162 }
163 }
164}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define free
Definition: debug_ros.c:5
#define PKFILE
Definition: getpublickey.c:51
GLuint res
Definition: glext.h:9613
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define err(...)
static int fd
Definition: io.c:51
Definition: cookie.c:42
Definition: copy.c:22
int ret

Referenced by __getpublickey_real().

◆ getpublickey()

int getpublickey ( char netname,
char publickey 
) const

Definition at line 166 of file getpublickey.c.

169{
171 return(__getpublickey_LOCAL(netname, publickey));
172 else
173 return(__getpublickey_real(netname, publickey));
174}
int __getpublickey_real(char *netname, char *publickey)
Definition: getpublickey.c:62
int(* __getpublickey_LOCAL)()=0
Definition: getpublickey.c:56

Referenced by _svcauth_des(), and authdes_seccreate().

Variable Documentation

◆ __getpublickey_LOCAL

int(* __getpublickey_LOCAL) ()=0 ( )

Definition at line 56 of file getpublickey.c.

Referenced by getpublickey().