PostgreSQL Source Code git master
Loading...
Searching...
No Matches
win32security.c File Reference
#include "postgres.h"
Include dependency graph for win32security.c:

Go to the source code of this file.

Functions

static void log_error (const char *fmt,...) pg_attribute_printf(1
 
int pgwin32_is_admin (void)
 
int pgwin32_is_service (void)
 

Function Documentation

◆ log_error()

static void static void log_error ( const char fmt,
  ... 
)
static

Definition at line 28 of file win32security.c.

29{
30 va_list ap;
31
32 va_start(ap, fmt);
33#ifndef FRONTEND
35#else
37#endif
38 va_end(ap);
39}
void vwrite_stderr(const char *fmt, va_list ap)
Definition elog.c:3809
#define vfprintf
Definition port.h:263
static int fb(int x)

References fb(), vfprintf, and vwrite_stderr().

◆ pgwin32_is_admin()

int pgwin32_is_admin ( void  )

Definition at line 49 of file win32security.c.

50{
56
59 DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0,
61 {
62 log_error(_("could not get SID for Administrators group: error code %lu\n"),
63 GetLastError());
64 exit(1);
65 }
66
69 DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0,
70 0, &PowerUsersSid))
71 {
72 log_error(_("could not get SID for PowerUsers group: error code %lu\n"),
73 GetLastError());
74 exit(1);
75 }
76
79 {
80 log_error(_("could not check access token membership: error code %lu\n"),
81 GetLastError());
82 exit(1);
83 }
84
87
89 return 1;
90 else
91 return 0;
92}
#define log_error(errcodefn,...)
Definition exec.c:66
#define _(x)
Definition elog.c:91

References _, fb(), and log_error.

Referenced by check_root().

◆ pgwin32_is_service()

int pgwin32_is_service ( void  )

Definition at line 120 of file win32security.c.

121{
122 static int _is_service = -1;
128
129 /* Only check the first time */
130 if (_is_service != -1)
131 return _is_service;
132
133 /* Check if standard error is not valid */
136 {
137 _is_service = 0;
138 return _is_service;
139 }
140
141 /* Check if running as LocalSystem */
143 SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0,
145 {
146 fprintf(stderr, "could not get SID for local system account\n");
147 return -1;
148 }
149
151 {
152 fprintf(stderr, "could not check access token membership: error code %lu\n",
153 GetLastError());
155 return -1;
156 }
158
159 if (IsMember)
160 {
161 _is_service = 1;
162 return _is_service;
163 }
164
165 /* Check for service group membership */
167 SECURITY_SERVICE_RID, 0, 0, 0, 0, 0, 0, 0,
168 &ServiceSid))
169 {
170 fprintf(stderr, "could not get SID for service group: error code %lu\n",
171 GetLastError());
172 return -1;
173 }
174
176 {
177 fprintf(stderr, "could not check access token membership: error code %lu\n",
178 GetLastError());
180 return -1;
181 }
183
184 if (IsMember)
185 _is_service = 1;
186 else
187 _is_service = 0;
188
189 return _is_service;
190}
#define fprintf(file, fmt, msg)
Definition cubescan.l:21

References fb(), and fprintf.

Referenced by send_message_to_server_log(), vwrite_stderr(), and write_stderr().