* security.cc (alloc_sd): Remove logsrv argument.
Remove two calls to lookup_name.
(set_security_attribute): Remove logsrv argument.
Remove logsrv argument in call to alloc_sd.
(set_nt_attribute): Remove logsrv argument.
Remove logsrv argument in call to set_security_attribute.
(set_file_attribute): Remove logsrv argument.
Remove logsrv argument in call to set_nt_attribute.
(set_file_attribute): Remove logsrv argument.
Remove logsrv argument in call to set_file_attribute.
* syscalls.cc (chown_worker): Remove logserver argument in
call to set_file_attribute.
(chmod): Ditto.
* shm.cc (shmget): Remove logsrv argument in call to alloc_sd.
* uinfo.cc (internal_getlogin): Replace calls to
lookup_name by call to LookupAccountName.
* security.h: Remove logsrv in declarations of set_file_attribute
and alloc_sd. Remove declaration of lookup_name.
+2002-06-03 Pierre Humblet <pierre.humblet@ieee.org>
+
+ * sec_helper.cc (lookup_name): Suppress.
+ * security.cc (alloc_sd): Remove logsrv argument.
+ Remove two calls to lookup_name.
+ (set_security_attribute): Remove logsrv argument.
+ Remove logsrv argument in call to alloc_sd.
+ (set_nt_attribute): Remove logsrv argument.
+ Remove logsrv argument in call to set_security_attribute.
+ (set_file_attribute): Remove logsrv argument.
+ Remove logsrv argument in call to set_nt_attribute.
+ (set_file_attribute): Remove logsrv argument.
+ Remove logsrv argument in call to set_file_attribute.
+ * syscalls.cc (chown_worker): Remove logserver argument in
+ call to set_file_attribute.
+ (chmod): Ditto.
+ * shm.cc (shmget): Remove logsrv argument in call to alloc_sd.
+ * uinfo.cc (internal_getlogin): Replace calls to
+ lookup_name by call to LookupAccountName.
+ * security.h: Remove logsrv in declarations of set_file_attribute
+ and alloc_sd. Remove declaration of lookup_name.
+
2002-06-05 Christopher Faylor <cgf@redhat.com>
* child_info.h (CHILD_INFO_MAGIC): Oops. Revert previous change. gcc
return grp_member;
}
+#if 0 // unused
#define SIDLEN (sidlen = MAX_SID_LEN, &sidlen)
#define DOMLEN (domlen = INTERNET_MAX_HOST_NAME_LENGTH, &domlen)
#undef SIDLEN
#undef DOMLEN
+#endif //unused
int
set_process_privilege (const char *privilege, BOOL enable)
}
PSECURITY_DESCRIPTOR
-alloc_sd (__uid32_t uid, __gid32_t gid, const char *logsrv, int attribute,
+alloc_sd (__uid32_t uid, __gid32_t gid, int attribute,
PSECURITY_DESCRIPTOR sd_ret, DWORD *sd_size_ret)
{
BOOL dummy;
cygsid owner_sid;
struct passwd *pw = getpwuid32 (uid);
strcpy (owner, pw ? pw->pw_name : getlogin ());
- if ((!pw || !owner_sid.getfrompw (pw))
- && !lookup_name (owner, logsrv, owner_sid))
+ if (!pw || !owner_sid.getfrompw (pw))
return NULL;
debug_printf ("owner: %s [%d]", owner,
*GetSidSubAuthority(owner_sid,
struct __group32 *grp = getgrgid32 (gid);
if (grp)
{
- if ((!grp || !group_sid.getfromgr (grp))
- && !lookup_name (grp->gr_name, logsrv, group_sid))
+ if (!grp || !group_sid.getfromgr (grp))
return NULL;
}
else
InitializeSecurityDescriptor ((PSECURITY_DESCRIPTOR)sd_buf,
SECURITY_DESCRIPTOR_REVISION);
psa->lpSecurityDescriptor = alloc_sd (geteuid32 (), getegid32 (),
- cygheap->user.logsrv (),
attribute, (PSECURITY_DESCRIPTOR)sd_buf,
&sd_buf_size);
}
static int
set_nt_attribute (const char *file, __uid32_t uid, __gid32_t gid,
- const char *logsrv, int attribute)
+ int attribute)
{
if (!wincap.has_security ())
return 0;
}
sd_size = 4096;
- if (!(psd = alloc_sd (uid, gid, logsrv, attribute, psd, &sd_size)))
+ if (!(psd = alloc_sd (uid, gid, attribute, psd, &sd_size)))
return -1;
return write_sd (file, psd, sd_size);
int
set_file_attribute (int use_ntsec, const char *file,
__uid32_t uid, __gid32_t gid,
- int attribute, const char *logsrv)
+ int attribute)
{
int ret = 0;
if (use_ntsec && allow_ntsec)
- ret = set_nt_attribute (file, uid, gid, logsrv, attribute);
+ ret = set_nt_attribute (file, uid, gid, attribute);
else if (allow_ntea && !NTWriteEA (file, ".UNIXATTR", (char *) &attribute,
sizeof (attribute)))
{
{
return set_file_attribute (use_ntsec, file,
myself->uid, myself->gid,
- attribute, cygheap->user.logsrv ());
+ attribute);
}
int __stdcall get_file_attribute (int, const char *, int *,
__uid32_t * = NULL, __gid32_t * = NULL);
int __stdcall set_file_attribute (int, const char *, int);
-int __stdcall set_file_attribute (int, const char *, __uid32_t, __gid32_t, int, const char *);
+int __stdcall set_file_attribute (int, const char *, __uid32_t, __gid32_t, int);
LONG __stdcall read_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, LPDWORD sd_size);
LONG __stdcall write_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, DWORD sd_size);
BOOL __stdcall add_access_allowed_ace (PACL acl, int offset, DWORD attributes, PSID sid, size_t &len_add, DWORD inherit);
/* sec_helper.cc: Security helper functions. */
BOOL __stdcall is_grp_member (__uid32_t uid, __gid32_t gid);
-/* `lookup_name' should be called instead of LookupAccountName.
- * logsrv may be NULL, in this case only the local system is used for lookup.
- * The buffer for ret_sid (40 Bytes) has to be allocated by the caller! */
-BOOL __stdcall lookup_name (const char *, const char *, PSID);
int set_process_privilege (const char *privilege, BOOL enable = TRUE);
/* shared.cc: */
int __stdcall NTReadEA (const char *file, const char *attrname, char *buf, int len);
BOOL __stdcall NTWriteEA (const char *file, const char *attrname, const char *buf, int len);
-PSECURITY_DESCRIPTOR alloc_sd (__uid32_t uid, __gid32_t gid, const char *logsrv, int attribute,
+PSECURITY_DESCRIPTOR alloc_sd (__uid32_t uid, __gid32_t gid, int attribute,
PSECURITY_DESCRIPTOR sd_ret, DWORD *sd_size_ret);
extern inline SECURITY_ATTRIBUTES *
/* create a sd for our open requests based on shmflag & 0x01ff */
InitializeSecurityDescriptor (psd,
SECURITY_DESCRIPTOR_REVISION);
- psd = alloc_sd (getuid32 (), getgid32 (), cygheap->user.logsrv (),
+ psd = alloc_sd (getuid32 (), getgid32 (),
shmflg & 0x01ff, psd, &sd_size);
if (key == (key_t) - 1)
if (win32_path.isdir())
attrib |= S_IFDIR;
res = set_file_attribute (win32_path.has_acls (), win32_path, uid,
- gid, attrib, cygheap->user.logsrv ());
+ gid, attrib);
}
if (res != 0 && (!win32_path.has_acls () || !allow_ntsec))
{
if (win32_path.isdir ())
mode |= S_IFDIR;
if (!set_file_attribute (win32_path.has_acls (), win32_path, uid, gid,
- mode, cygheap->user.logsrv ())
+ mode)
&& allow_ntsec)
res = 0;
and a domain user may have the same name. */
if (!ret && user.domain ())
{
+ char domain[DNLEN + 1];
+ DWORD dlen = sizeof (domain);
+ siz = sizeof (tu);
+ SID_NAME_USE use = SidTypeInvalid;
/* Concat DOMAIN\USERNAME for the next lookup */
strcat (strcat (strcpy (buf, user.domain ()), "\\"), user.name ());
- if (!(ret = lookup_name (buf, NULL, user.sid ())))
- debug_printf ("Couldn't retrieve SID locally!");
- }
+ if (!LookupAccountName (NULL, buf, tu, &siz,
+ domain, &dlen, &use) ||
+ !legal_sid_type (use))
+ debug_printf ("Couldn't retrieve SID locally!");
+ else user.set_sid (tu);
- /* If that fails, too, as a last resort try to get the SID from
- the logon server. */
- if (!ret && !(ret = lookup_name (user.name (), user.logsrv (),
- user.sid ())))
- debug_printf ("Couldn't retrieve SID from '%s'!", user.logsrv ());
+ }
/* If we have a SID, try to get the corresponding Cygwin user name
which can be different from the Windows user name. */