* grp.cc: Eliminate MAX_DOMAIN_NAME define.
(read_etc_group): Substitute MAX_DOMAIN_NAME by INTERNET_MAX_HOST_NAME_LENGTH. * passwd.cc (parse_pwd): Don't force pw_name to be lower case. * sec_helper.cc: Substitute MAX_USER_NAME by UNLEN, MAX_COMPUTERNAME_LENGTH by INTERNET_MAX_HOST_NAME_LENGTH throughout. (lookup_name): Slight cleanup. * security.cc (alloc_sd): Substitute MAX_USER_NAME by UNLEN. * security.h: Define DEFAULT_UID as DOMAIN_USER_RID_ADMIN and DEFAULT_GID as DOMAIN_ALIAS_RID_ADMINS. * shared.cc (memory_init): Substitute MAX_USER_NAME by UNLEN. * thread.h: Ditto. * uinfo.cc (internal_getlogin): Substitute MAX_USER_NAME by UNLEN. Substitute MAX_COMPUTERNAME_LENGTH and MAX_HOST_NAME by INTERNET_MAX_HOST_NAME_LENGTH. * winsup.h: Include lmcons.h. Eliminate MAX_USER_NAME and MAX_HOST_NAME. Move DEFAULT_UID and DEFAULT_GID to security.h.
This commit is contained in:
parent
c0a45b92cc
commit
17db110558
|
@ -1,3 +1,23 @@
|
||||||
|
Mon Apr 30 19:58:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* grp.cc: Eliminate MAX_DOMAIN_NAME define.
|
||||||
|
(read_etc_group): Substitute MAX_DOMAIN_NAME by
|
||||||
|
INTERNET_MAX_HOST_NAME_LENGTH.
|
||||||
|
* passwd.cc (parse_pwd): Don't force pw_name to be lower case.
|
||||||
|
* sec_helper.cc: Substitute MAX_USER_NAME by UNLEN,
|
||||||
|
MAX_COMPUTERNAME_LENGTH by INTERNET_MAX_HOST_NAME_LENGTH throughout.
|
||||||
|
(lookup_name): Slight cleanup.
|
||||||
|
* security.cc (alloc_sd): Substitute MAX_USER_NAME by UNLEN.
|
||||||
|
* security.h: Define DEFAULT_UID as DOMAIN_USER_RID_ADMIN and
|
||||||
|
DEFAULT_GID as DOMAIN_ALIAS_RID_ADMINS.
|
||||||
|
* shared.cc (memory_init): Substitute MAX_USER_NAME by UNLEN.
|
||||||
|
* thread.h: Ditto.
|
||||||
|
* uinfo.cc (internal_getlogin): Substitute MAX_USER_NAME by UNLEN.
|
||||||
|
Substitute MAX_COMPUTERNAME_LENGTH and MAX_HOST_NAME by
|
||||||
|
INTERNET_MAX_HOST_NAME_LENGTH.
|
||||||
|
* winsup.h: Include lmcons.h. Eliminate MAX_USER_NAME and
|
||||||
|
MAX_HOST_NAME. Move DEFAULT_UID and DEFAULT_GID to security.h.
|
||||||
|
|
||||||
Mon Apr 30 12:35:40 2001 Christopher Faylor <cgf@cygnus.com>
|
Mon Apr 30 12:35:40 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* path.cc (path_conv::check): Don't use path_flags when converting to
|
* path.cc (path_conv::check): Don't use path_flags when converting to
|
||||||
|
|
|
@ -13,6 +13,7 @@ details. */
|
||||||
|
|
||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
|
#include <wininet.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -28,8 +29,6 @@ details. */
|
||||||
/* Read /etc/group only once for better performance. This is done
|
/* Read /etc/group only once for better performance. This is done
|
||||||
on the first call that needs information from it. */
|
on the first call that needs information from it. */
|
||||||
|
|
||||||
#define MAX_DOMAIN_NAME 100
|
|
||||||
|
|
||||||
static NO_COPY const char *etc_group = "/etc/group";
|
static NO_COPY const char *etc_group = "/etc/group";
|
||||||
static struct group *group_buf = NULL; /* group contents in memory */
|
static struct group *group_buf = NULL; /* group contents in memory */
|
||||||
static int curr_lines = 0;
|
static int curr_lines = 0;
|
||||||
|
@ -138,8 +137,8 @@ void
|
||||||
read_etc_group ()
|
read_etc_group ()
|
||||||
{
|
{
|
||||||
char linebuf [200];
|
char linebuf [200];
|
||||||
char group_name [MAX_USER_NAME];
|
char group_name [UNLEN + 1];
|
||||||
DWORD group_name_len = MAX_USER_NAME;
|
DWORD group_name_len = UNLEN + 1;
|
||||||
|
|
||||||
strncpy (group_name, "Administrators", sizeof (group_name));
|
strncpy (group_name, "Administrators", sizeof (group_name));
|
||||||
|
|
||||||
|
@ -172,8 +171,8 @@ read_etc_group ()
|
||||||
}
|
}
|
||||||
else /* /etc/group doesn't exist -- create default one in memory */
|
else /* /etc/group doesn't exist -- create default one in memory */
|
||||||
{
|
{
|
||||||
char domain_name [MAX_DOMAIN_NAME];
|
char domain_name [INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
||||||
DWORD domain_name_len = MAX_DOMAIN_NAME;
|
DWORD domain_name_len = INTERNET_MAX_HOST_NAME_LENGTH + 1;
|
||||||
SID_NAME_USE acType;
|
SID_NAME_USE acType;
|
||||||
debug_printf ("Emulating /etc/group");
|
debug_printf ("Emulating /etc/group");
|
||||||
if (! LookupAccountSidA (NULL ,
|
if (! LookupAccountSidA (NULL ,
|
||||||
|
|
|
@ -20,6 +20,7 @@ details. */
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
#include "security.h"
|
||||||
#include <sys/termios.h>
|
#include <sys/termios.h>
|
||||||
|
|
||||||
/* Read /etc/passwd only once for better performance. This is done
|
/* Read /etc/passwd only once for better performance. This is done
|
||||||
|
@ -93,7 +94,7 @@ parse_pwd (struct passwd &res, char *buf)
|
||||||
if (mybuf[--len] == '\n')
|
if (mybuf[--len] == '\n')
|
||||||
mybuf[len] = '\0';
|
mybuf[len] = '\0';
|
||||||
|
|
||||||
res.pw_name = strlwr (grab_string (&mybuf));
|
res.pw_name = grab_string (&mybuf);
|
||||||
res.pw_passwd = grab_string (&mybuf);
|
res.pw_passwd = grab_string (&mybuf);
|
||||||
res.pw_uid = grab_int (&mybuf);
|
res.pw_uid = grab_int (&mybuf);
|
||||||
res.pw_gid = grab_int (&mybuf);
|
res.pw_gid = grab_int (&mybuf);
|
||||||
|
|
|
@ -23,6 +23,7 @@ details. */
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <wingdi.h>
|
#include <wingdi.h>
|
||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
|
#include <wininet.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
|
@ -221,10 +222,10 @@ get_id_from_sid (PSID psid, BOOL search_grp, int *type)
|
||||||
*/
|
*/
|
||||||
if (id == -1 || type)
|
if (id == -1 || type)
|
||||||
{
|
{
|
||||||
char account[MAX_USER_NAME];
|
char account[UNLEN + 1];
|
||||||
char domain[MAX_COMPUTERNAME_LENGTH+1];
|
char domain[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
||||||
DWORD acc_len = MAX_USER_NAME;
|
DWORD acc_len = UNLEN + 1;
|
||||||
DWORD dom_len = MAX_COMPUTERNAME_LENGTH+1;
|
DWORD dom_len = INTERNET_MAX_HOST_NAME_LENGTH + 1;
|
||||||
SID_NAME_USE acc_type;
|
SID_NAME_USE acc_type;
|
||||||
|
|
||||||
if (!LookupAccountSid (NULL, psid, account, &acc_len,
|
if (!LookupAccountSid (NULL, psid, account, &acc_len,
|
||||||
|
@ -299,13 +300,16 @@ is_grp_member (uid_t uid, gid_t gid)
|
||||||
return grp_member;
|
return grp_member;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SIDLEN (sidlen = MAX_SID_LEN, &sidlen)
|
||||||
|
#define DOMLEN (domlen = INTERNET_MAX_HOST_NAME_LENGTH, &domlen)
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
lookup_name (const char *name, const char *logsrv, PSID ret_sid)
|
lookup_name (const char *name, const char *logsrv, PSID ret_sid)
|
||||||
{
|
{
|
||||||
cygsid sid;
|
cygsid sid;
|
||||||
DWORD sidlen;
|
DWORD sidlen;
|
||||||
char domuser[MAX_COMPUTERNAME_LENGTH+MAX_USER_NAME+1];
|
char domuser[INTERNET_MAX_HOST_NAME_LENGTH + UNLEN + 2];
|
||||||
char dom[MAX_COMPUTERNAME_LENGTH+1];
|
char dom[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
||||||
DWORD domlen;
|
DWORD domlen;
|
||||||
SID_NAME_USE acc_type;
|
SID_NAME_USE acc_type;
|
||||||
|
|
||||||
|
@ -317,51 +321,35 @@ lookup_name (const char *name, const char *logsrv, PSID ret_sid)
|
||||||
if (cygheap->user.domain ())
|
if (cygheap->user.domain ())
|
||||||
{
|
{
|
||||||
strcat (strcat (strcpy (domuser, cygheap->user.domain ()), "\\"), name);
|
strcat (strcat (strcpy (domuser, cygheap->user.domain ()), "\\"), name);
|
||||||
if (LookupAccountName (NULL, domuser,
|
if (LookupAccountName (NULL, domuser, sid, SIDLEN, dom, DOMLEN, &acc_type)
|
||||||
sid, (sidlen = MAX_SID_LEN, &sidlen),
|
|
||||||
dom, (domlen = MAX_COMPUTERNAME_LENGTH, &domlen),
|
|
||||||
&acc_type)
|
|
||||||
&& legal_sid_type (acc_type))
|
&& legal_sid_type (acc_type))
|
||||||
goto got_it;
|
goto got_it;
|
||||||
if (logsrv && *logsrv
|
if (logsrv && *logsrv
|
||||||
&& LookupAccountName (logsrv, domuser,
|
&& LookupAccountName (logsrv, domuser, sid, SIDLEN,
|
||||||
sid, (sidlen = MAX_SID_LEN, &sidlen),
|
dom, DOMLEN, &acc_type)
|
||||||
dom, (domlen = MAX_COMPUTERNAME_LENGTH,&domlen),
|
|
||||||
&acc_type)
|
|
||||||
&& legal_sid_type (acc_type))
|
&& legal_sid_type (acc_type))
|
||||||
goto got_it;
|
goto got_it;
|
||||||
}
|
}
|
||||||
if (logsrv && *logsrv)
|
if (logsrv && *logsrv)
|
||||||
{
|
{
|
||||||
if (LookupAccountName (logsrv, name,
|
if (LookupAccountName (logsrv, name, sid, SIDLEN, dom, DOMLEN, &acc_type)
|
||||||
sid, (sidlen = MAX_SID_LEN, &sidlen),
|
|
||||||
dom, (domlen = MAX_COMPUTERNAME_LENGTH, &domlen),
|
|
||||||
&acc_type)
|
|
||||||
&& legal_sid_type (acc_type))
|
&& legal_sid_type (acc_type))
|
||||||
goto got_it;
|
goto got_it;
|
||||||
if (acc_type == SidTypeDomain)
|
if (acc_type == SidTypeDomain)
|
||||||
{
|
{
|
||||||
strcat (strcat (strcpy (domuser, dom), "\\"), name);
|
strcat (strcat (strcpy (domuser, dom), "\\"), name);
|
||||||
if (LookupAccountName (logsrv, domuser,
|
if (LookupAccountName (logsrv, domuser, sid, SIDLEN,
|
||||||
sid,(sidlen = MAX_SID_LEN, &sidlen),
|
dom, DOMLEN, &acc_type))
|
||||||
dom,(domlen = MAX_COMPUTERNAME_LENGTH,&domlen),
|
|
||||||
&acc_type))
|
|
||||||
goto got_it;
|
goto got_it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (LookupAccountName (NULL, name,
|
if (LookupAccountName (NULL, name, sid, SIDLEN, dom, DOMLEN, &acc_type)
|
||||||
sid, (sidlen = MAX_SID_LEN, &sidlen),
|
|
||||||
dom, (domlen = 100, &domlen),
|
|
||||||
&acc_type)
|
|
||||||
&& legal_sid_type (acc_type))
|
&& legal_sid_type (acc_type))
|
||||||
goto got_it;
|
goto got_it;
|
||||||
if (acc_type == SidTypeDomain)
|
if (acc_type == SidTypeDomain)
|
||||||
{
|
{
|
||||||
strcat (strcat (strcpy (domuser, dom), "\\"), name);
|
strcat (strcat (strcpy (domuser, dom), "\\"), name);
|
||||||
if (LookupAccountName (NULL, domuser,
|
if (LookupAccountName (NULL, domuser, sid, SIDLEN, dom, DOMLEN,&acc_type))
|
||||||
sid, (sidlen = MAX_SID_LEN, &sidlen),
|
|
||||||
dom, (domlen = MAX_COMPUTERNAME_LENGTH, &domlen),
|
|
||||||
&acc_type))
|
|
||||||
goto got_it;
|
goto got_it;
|
||||||
}
|
}
|
||||||
debug_printf ("LookupAccountName(%s) %E", name);
|
debug_printf ("LookupAccountName(%s) %E", name);
|
||||||
|
@ -378,6 +366,9 @@ got_it:
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef SIDLEN
|
||||||
|
#undef DOMLEN
|
||||||
|
|
||||||
int
|
int
|
||||||
set_process_privilege (const char *privilege, BOOL enable)
|
set_process_privilege (const char *privilege, BOOL enable)
|
||||||
{
|
{
|
||||||
|
|
|
@ -468,7 +468,7 @@ alloc_sd (uid_t uid, gid_t gid, const char *logsrv, int attribute,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get SID and name of new owner. */
|
/* Get SID and name of new owner. */
|
||||||
char owner[MAX_USER_NAME];
|
char owner[UNLEN + 1];
|
||||||
cygsid owner_sid;
|
cygsid owner_sid;
|
||||||
struct passwd *pw = getpwuid (uid);
|
struct passwd *pw = getpwuid (uid);
|
||||||
strcpy (owner, pw ? pw->pw_name : getlogin ());
|
strcpy (owner, pw ? pw->pw_name : getlogin ());
|
||||||
|
|
|
@ -14,6 +14,9 @@ details. */
|
||||||
|
|
||||||
#define MAX_SID_LEN 40
|
#define MAX_SID_LEN 40
|
||||||
|
|
||||||
|
#define DEFAULT_UID DOMAIN_USER_RID_ADMIN
|
||||||
|
#define DEFAULT_GID DOMAIN_ALIAS_RID_ADMINS
|
||||||
|
|
||||||
class cygsid {
|
class cygsid {
|
||||||
PSID psid;
|
PSID psid;
|
||||||
char sbuf[MAX_SID_LEN];
|
char sbuf[MAX_SID_LEN];
|
||||||
|
|
|
@ -154,8 +154,8 @@ memory_init ()
|
||||||
heap_init ();
|
heap_init ();
|
||||||
|
|
||||||
/* Allocate memory for the per-user mount table */
|
/* Allocate memory for the per-user mount table */
|
||||||
char user_name[MAX_USER_NAME];
|
char user_name[UNLEN + 1];
|
||||||
DWORD user_name_len = MAX_USER_NAME;
|
DWORD user_name_len = UNLEN + 1;
|
||||||
|
|
||||||
if (!GetUserName (user_name, &user_name_len))
|
if (!GetUserName (user_name, &user_name_len))
|
||||||
strcpy (user_name, "unknown");
|
strcpy (user_name, "unknown");
|
||||||
|
|
|
@ -93,7 +93,7 @@ struct _winsup_t
|
||||||
struct tm _localtime_buf;
|
struct tm _localtime_buf;
|
||||||
|
|
||||||
/* uinfo.cc */
|
/* uinfo.cc */
|
||||||
char _username[MAX_USER_NAME];
|
char _username[UNLEN + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ details. */
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <winnls.h>
|
#include <winnls.h>
|
||||||
|
#include <wininet.h>
|
||||||
#include <utmp.h>
|
#include <utmp.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -29,8 +30,8 @@ details. */
|
||||||
struct passwd *
|
struct passwd *
|
||||||
internal_getlogin (cygheap_user &user)
|
internal_getlogin (cygheap_user &user)
|
||||||
{
|
{
|
||||||
char username[MAX_USER_NAME];
|
char username[UNLEN + 1];
|
||||||
DWORD username_len = MAX_USER_NAME;
|
DWORD username_len = UNLEN + 1;
|
||||||
struct passwd *pw = NULL;
|
struct passwd *pw = NULL;
|
||||||
|
|
||||||
if (!user.name ())
|
if (!user.name ())
|
||||||
|
@ -62,19 +63,19 @@ internal_getlogin (cygheap_user &user)
|
||||||
{
|
{
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
|
||||||
sys_wcstombs (buf, wui->wkui1_username, MAX_USER_NAME);
|
sys_wcstombs (buf, wui->wkui1_username, UNLEN + 1);
|
||||||
user.set_name (buf);
|
user.set_name (buf);
|
||||||
sys_wcstombs (buf, wui->wkui1_logon_server, MAX_HOST_NAME);
|
sys_wcstombs (buf, wui->wkui1_logon_server, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||||
user.set_logsrv (buf);
|
user.set_logsrv (buf);
|
||||||
sys_wcstombs (buf, wui->wkui1_logon_domain,
|
sys_wcstombs (buf, wui->wkui1_logon_domain,
|
||||||
MAX_COMPUTERNAME_LENGTH + 1);
|
INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||||
user.set_domain (buf);
|
user.set_domain (buf);
|
||||||
/* Save values in environment */
|
/* Save values in environment */
|
||||||
if (!strcasematch (user.name (), "SYSTEM")
|
if (!strcasematch (user.name (), "SYSTEM")
|
||||||
&& user.domain () && user.logsrv ())
|
&& user.domain () && user.logsrv ())
|
||||||
{
|
{
|
||||||
LPUSER_INFO_3 ui = NULL;
|
LPUSER_INFO_3 ui = NULL;
|
||||||
WCHAR wbuf[MAX_HOST_NAME + 2];
|
WCHAR wbuf[INTERNET_MAX_HOST_NAME_LENGTH + 2];
|
||||||
|
|
||||||
strcat (strcpy (buf, "\\\\"), user.logsrv ());
|
strcat (strcpy (buf, "\\\\"), user.logsrv ());
|
||||||
setenv ("USERNAME", user.name (), 1);
|
setenv ("USERNAME", user.name (), 1);
|
||||||
|
@ -82,7 +83,7 @@ internal_getlogin (cygheap_user &user)
|
||||||
setenv ("USERDOMAIN", user.domain (), 1);
|
setenv ("USERDOMAIN", user.domain (), 1);
|
||||||
/* HOMEDRIVE and HOMEPATH are wrong most of the time, too,
|
/* HOMEDRIVE and HOMEPATH are wrong most of the time, too,
|
||||||
after changing user context! */
|
after changing user context! */
|
||||||
sys_mbstowcs (wbuf, buf, MAX_HOST_NAME + 2);
|
sys_mbstowcs (wbuf, buf, INTERNET_MAX_HOST_NAME_LENGTH + 2);
|
||||||
if (!NetUserGetInfo (NULL, wui->wkui1_username, 3, (LPBYTE *)&ui)
|
if (!NetUserGetInfo (NULL, wui->wkui1_username, 3, (LPBYTE *)&ui)
|
||||||
|| !NetUserGetInfo (wbuf,wui->wkui1_username,3,(LPBYTE *)&ui))
|
|| !NetUserGetInfo (wbuf,wui->wkui1_username,3,(LPBYTE *)&ui))
|
||||||
{
|
{
|
||||||
|
@ -237,7 +238,7 @@ getlogin (void)
|
||||||
#ifdef _MT_SAFE
|
#ifdef _MT_SAFE
|
||||||
char *this_username=_reent_winsup ()->_username;
|
char *this_username=_reent_winsup ()->_username;
|
||||||
#else
|
#else
|
||||||
static NO_COPY char this_username[MAX_USER_NAME];
|
static NO_COPY char this_username[UNLEN + 1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return strcpy (this_username, cygheap->user.name ());
|
return strcpy (this_username, cygheap->user.name ());
|
||||||
|
|
|
@ -71,6 +71,7 @@ extern char case_folded_upper[];
|
||||||
#define _WINSVC_H
|
#define _WINSVC_H
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wincrypt.h>
|
#include <wincrypt.h>
|
||||||
|
#include <lmcons.h>
|
||||||
#undef _WINGDI_H
|
#undef _WINGDI_H
|
||||||
#undef _WINUSER_H
|
#undef _WINUSER_H
|
||||||
#undef _WINNLS_H
|
#undef _WINNLS_H
|
||||||
|
@ -97,11 +98,6 @@ extern int dynamically_loaded;
|
||||||
MultiByteToWideChar((current_codepage==ansi_cp?CP_ACP:CP_OEMCP),0,(src),-1,(tgt),(len))
|
MultiByteToWideChar((current_codepage==ansi_cp?CP_ACP:CP_OEMCP),0,(src),-1,(tgt),(len))
|
||||||
|
|
||||||
#define TITLESIZE 1024
|
#define TITLESIZE 1024
|
||||||
#define MAX_USER_NAME 20
|
|
||||||
#define DEFAULT_UID 500
|
|
||||||
#define DEFAULT_GID 544
|
|
||||||
|
|
||||||
#define MAX_HOST_NAME 256
|
|
||||||
|
|
||||||
/* status bit manipulation */
|
/* status bit manipulation */
|
||||||
#define __ISSETF(what, x, prefix) \
|
#define __ISSETF(what, x, prefix) \
|
||||||
|
|
Loading…
Reference in New Issue