aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog20
-rw-r--r--winsup/cygwin/grp.cc11
-rw-r--r--winsup/cygwin/passwd.cc3
-rw-r--r--winsup/cygwin/sec_helper.cc51
-rw-r--r--winsup/cygwin/security.cc2
-rw-r--r--winsup/cygwin/security.h3
-rw-r--r--winsup/cygwin/shared.cc4
-rw-r--r--winsup/cygwin/thread.h2
-rw-r--r--winsup/cygwin/uinfo.cc17
-rw-r--r--winsup/cygwin/winsup.h6
10 files changed, 65 insertions, 54 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 8a201ef..06db22a 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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>
* path.cc (path_conv::check): Don't use path_flags when converting to
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index 2cd8b5e..231501e 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -13,6 +13,7 @@ details. */
#include "winsup.h"
#include <grp.h>
+#include <wininet.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -28,8 +29,6 @@ details. */
/* Read /etc/group only once for better performance. This is done
on the first call that needs information from it. */
-#define MAX_DOMAIN_NAME 100
-
static NO_COPY const char *etc_group = "/etc/group";
static struct group *group_buf = NULL; /* group contents in memory */
static int curr_lines = 0;
@@ -138,8 +137,8 @@ void
read_etc_group ()
{
char linebuf [200];
- char group_name [MAX_USER_NAME];
- DWORD group_name_len = MAX_USER_NAME;
+ char group_name [UNLEN + 1];
+ DWORD group_name_len = UNLEN + 1;
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 */
{
- char domain_name [MAX_DOMAIN_NAME];
- DWORD domain_name_len = MAX_DOMAIN_NAME;
+ char domain_name [INTERNET_MAX_HOST_NAME_LENGTH + 1];
+ DWORD domain_name_len = INTERNET_MAX_HOST_NAME_LENGTH + 1;
SID_NAME_USE acType;
debug_printf ("Emulating /etc/group");
if (! LookupAccountSidA (NULL ,
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc
index 3b6494c..6959f34 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -20,6 +20,7 @@ details. */
#include "sigproc.h"
#include "pinfo.h"
#include "cygheap.h"
+#include "security.h"
#include <sys/termios.h>
/* 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')
mybuf[len] = '\0';
- res.pw_name = strlwr (grab_string (&mybuf));
+ res.pw_name = grab_string (&mybuf);
res.pw_passwd = grab_string (&mybuf);
res.pw_uid = grab_int (&mybuf);
res.pw_gid = grab_int (&mybuf);
diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc
index d360641..e3eaa09 100644
--- a/winsup/cygwin/sec_helper.cc
+++ b/winsup/cygwin/sec_helper.cc
@@ -23,6 +23,7 @@ details. */
#include <ctype.h>
#include <wingdi.h>
#include <winuser.h>
+#include <wininet.h>
#include "cygerrno.h"
#include "perprocess.h"
#include "fhandler.h"
@@ -221,10 +222,10 @@ get_id_from_sid (PSID psid, BOOL search_grp, int *type)
*/
if (id == -1 || type)
{
- char account[MAX_USER_NAME];
- char domain[MAX_COMPUTERNAME_LENGTH+1];
- DWORD acc_len = MAX_USER_NAME;
- DWORD dom_len = MAX_COMPUTERNAME_LENGTH+1;
+ char account[UNLEN + 1];
+ char domain[INTERNET_MAX_HOST_NAME_LENGTH + 1];
+ DWORD acc_len = UNLEN + 1;
+ DWORD dom_len = INTERNET_MAX_HOST_NAME_LENGTH + 1;
SID_NAME_USE acc_type;
if (!LookupAccountSid (NULL, psid, account, &acc_len,
@@ -299,13 +300,16 @@ is_grp_member (uid_t uid, gid_t gid)
return grp_member;
}
+#define SIDLEN (sidlen = MAX_SID_LEN, &sidlen)
+#define DOMLEN (domlen = INTERNET_MAX_HOST_NAME_LENGTH, &domlen)
+
BOOL
lookup_name (const char *name, const char *logsrv, PSID ret_sid)
{
cygsid sid;
DWORD sidlen;
- char domuser[MAX_COMPUTERNAME_LENGTH+MAX_USER_NAME+1];
- char dom[MAX_COMPUTERNAME_LENGTH+1];
+ char domuser[INTERNET_MAX_HOST_NAME_LENGTH + UNLEN + 2];
+ char dom[INTERNET_MAX_HOST_NAME_LENGTH + 1];
DWORD domlen;
SID_NAME_USE acc_type;
@@ -317,51 +321,35 @@ lookup_name (const char *name, const char *logsrv, PSID ret_sid)
if (cygheap->user.domain ())
{
strcat (strcat (strcpy (domuser, cygheap->user.domain ()), "\\"), name);
- if (LookupAccountName (NULL, domuser,
- sid, (sidlen = MAX_SID_LEN, &sidlen),
- dom, (domlen = MAX_COMPUTERNAME_LENGTH, &domlen),
- &acc_type)
+ if (LookupAccountName (NULL, domuser, sid, SIDLEN, dom, DOMLEN, &acc_type)
&& legal_sid_type (acc_type))
goto got_it;
if (logsrv && *logsrv
- && LookupAccountName (logsrv, domuser,
- sid, (sidlen = MAX_SID_LEN, &sidlen),
- dom, (domlen = MAX_COMPUTERNAME_LENGTH,&domlen),
- &acc_type)
+ && LookupAccountName (logsrv, domuser, sid, SIDLEN,
+ dom, DOMLEN, &acc_type)
&& legal_sid_type (acc_type))
goto got_it;
}
if (logsrv && *logsrv)
{
- if (LookupAccountName (logsrv, name,
- sid, (sidlen = MAX_SID_LEN, &sidlen),
- dom, (domlen = MAX_COMPUTERNAME_LENGTH, &domlen),
- &acc_type)
+ if (LookupAccountName (logsrv, name, sid, SIDLEN, dom, DOMLEN, &acc_type)
&& legal_sid_type (acc_type))
goto got_it;
if (acc_type == SidTypeDomain)
{
strcat (strcat (strcpy (domuser, dom), "\\"), name);
- if (LookupAccountName (logsrv, domuser,
- sid,(sidlen = MAX_SID_LEN, &sidlen),
- dom,(domlen = MAX_COMPUTERNAME_LENGTH,&domlen),
- &acc_type))
+ if (LookupAccountName (logsrv, domuser, sid, SIDLEN,
+ dom, DOMLEN, &acc_type))
goto got_it;
}
}
- if (LookupAccountName (NULL, name,
- sid, (sidlen = MAX_SID_LEN, &sidlen),
- dom, (domlen = 100, &domlen),
- &acc_type)
+ if (LookupAccountName (NULL, name, sid, SIDLEN, dom, DOMLEN, &acc_type)
&& legal_sid_type (acc_type))
goto got_it;
if (acc_type == SidTypeDomain)
{
strcat (strcat (strcpy (domuser, dom), "\\"), name);
- if (LookupAccountName (NULL, domuser,
- sid, (sidlen = MAX_SID_LEN, &sidlen),
- dom, (domlen = MAX_COMPUTERNAME_LENGTH, &domlen),
- &acc_type))
+ if (LookupAccountName (NULL, domuser, sid, SIDLEN, dom, DOMLEN,&acc_type))
goto got_it;
}
debug_printf ("LookupAccountName(%s) %E", name);
@@ -378,6 +366,9 @@ got_it:
return TRUE;
}
+#undef SIDLEN
+#undef DOMLEN
+
int
set_process_privilege (const char *privilege, BOOL enable)
{
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index b24d648..9077676 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -468,7 +468,7 @@ alloc_sd (uid_t uid, gid_t gid, const char *logsrv, int attribute,
}
/* Get SID and name of new owner. */
- char owner[MAX_USER_NAME];
+ char owner[UNLEN + 1];
cygsid owner_sid;
struct passwd *pw = getpwuid (uid);
strcpy (owner, pw ? pw->pw_name : getlogin ());
diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h
index 98545b6..d56483b 100644
--- a/winsup/cygwin/security.h
+++ b/winsup/cygwin/security.h
@@ -14,6 +14,9 @@ details. */
#define MAX_SID_LEN 40
+#define DEFAULT_UID DOMAIN_USER_RID_ADMIN
+#define DEFAULT_GID DOMAIN_ALIAS_RID_ADMINS
+
class cygsid {
PSID psid;
char sbuf[MAX_SID_LEN];
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index 599685c..2312d81 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -154,8 +154,8 @@ memory_init ()
heap_init ();
/* Allocate memory for the per-user mount table */
- char user_name[MAX_USER_NAME];
- DWORD user_name_len = MAX_USER_NAME;
+ char user_name[UNLEN + 1];
+ DWORD user_name_len = UNLEN + 1;
if (!GetUserName (user_name, &user_name_len))
strcpy (user_name, "unknown");
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h
index 39f0f58..a43d9fe 100644
--- a/winsup/cygwin/thread.h
+++ b/winsup/cygwin/thread.h
@@ -93,7 +93,7 @@ struct _winsup_t
struct tm _localtime_buf;
/* uinfo.cc */
- char _username[MAX_USER_NAME];
+ char _username[UNLEN + 1];
};
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index c7b97e3..3706e4a 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -12,6 +12,7 @@ details. */
#include <pwd.h>
#include <unistd.h>
#include <winnls.h>
+#include <wininet.h>
#include <utmp.h>
#include <limits.h>
#include <stdlib.h>
@@ -29,8 +30,8 @@ details. */
struct passwd *
internal_getlogin (cygheap_user &user)
{
- char username[MAX_USER_NAME];
- DWORD username_len = MAX_USER_NAME;
+ char username[UNLEN + 1];
+ DWORD username_len = UNLEN + 1;
struct passwd *pw = NULL;
if (!user.name ())
@@ -62,19 +63,19 @@ internal_getlogin (cygheap_user &user)
{
char buf[512];
- sys_wcstombs (buf, wui->wkui1_username, MAX_USER_NAME);
+ sys_wcstombs (buf, wui->wkui1_username, UNLEN + 1);
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);
sys_wcstombs (buf, wui->wkui1_logon_domain,
- MAX_COMPUTERNAME_LENGTH + 1);
+ INTERNET_MAX_HOST_NAME_LENGTH + 1);
user.set_domain (buf);
/* Save values in environment */
if (!strcasematch (user.name (), "SYSTEM")
&& user.domain () && user.logsrv ())
{
LPUSER_INFO_3 ui = NULL;
- WCHAR wbuf[MAX_HOST_NAME + 2];
+ WCHAR wbuf[INTERNET_MAX_HOST_NAME_LENGTH + 2];
strcat (strcpy (buf, "\\\\"), user.logsrv ());
setenv ("USERNAME", user.name (), 1);
@@ -82,7 +83,7 @@ internal_getlogin (cygheap_user &user)
setenv ("USERDOMAIN", user.domain (), 1);
/* HOMEDRIVE and HOMEPATH are wrong most of the time, too,
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)
|| !NetUserGetInfo (wbuf,wui->wkui1_username,3,(LPBYTE *)&ui))
{
@@ -237,7 +238,7 @@ getlogin (void)
#ifdef _MT_SAFE
char *this_username=_reent_winsup ()->_username;
#else
- static NO_COPY char this_username[MAX_USER_NAME];
+ static NO_COPY char this_username[UNLEN + 1];
#endif
return strcpy (this_username, cygheap->user.name ());
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 663e999..81ec231 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -71,6 +71,7 @@ extern char case_folded_upper[];
#define _WINSVC_H
#include <windows.h>
#include <wincrypt.h>
+#include <lmcons.h>
#undef _WINGDI_H
#undef _WINUSER_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))
#define TITLESIZE 1024
-#define MAX_USER_NAME 20
-#define DEFAULT_UID 500
-#define DEFAULT_GID 544
-
-#define MAX_HOST_NAME 256
/* status bit manipulation */
#define __ISSETF(what, x, prefix) \