Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-03-01 06:38:19 +0300
committerChristopher Faylor <me@cgf.cx>2003-03-01 06:38:19 +0300
commitdbc49afd5279aa30ca5ca98189443c69f65e6a22 (patch)
tree5a44790ef12d900dcb50e0940818427c8f92469c
parent005c3065ebdbdf897733268edce15aeb0e7e9fd6 (diff)
* Makefile.in (cygcheck.o): Fix so that actual mingw include files are used.
* cygcheck.cc (find_on_path): Translate from cygwin path when qualified path name found. (pretty_id): New function. Dump output of id command. (dump_sysinfo): Call pretty_id for CYGWIN=ntsec and CYGWIN=nontsec cases.
-rw-r--r--winsup/utils/ChangeLog9
-rw-r--r--winsup/utils/Makefile.in4
-rw-r--r--winsup/utils/cygcheck.cc86
3 files changed, 94 insertions, 5 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog
index 91b2afa13..6fd2041bd 100644
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -1,3 +1,12 @@
+2003-02-28 Christopher Faylor <cgf@redhat.com>
+
+ * Makefile.in (cygcheck.o): Fix so that actual mingw include files are
+ used.
+ * cygcheck.cc (find_on_path): Translate from cygwin path when qualified
+ path name found.
+ (pretty_id): New function. Dump output of id command.
+ (dump_sysinfo): Call pretty_id for CYGWIN=ntsec and CYGWIN=nontsec cases.
+
2003-02-12 Christopher Faylor <cgf@redhat.com>
* cygpath.cc (doit): Allocate more space for non-path filename.
diff --git a/winsup/utils/Makefile.in b/winsup/utils/Makefile.in
index 1b8440528..0c4e5bc3b 100644
--- a/winsup/utils/Makefile.in
+++ b/winsup/utils/Makefile.in
@@ -147,10 +147,10 @@ endif
cygcheck.o: cygcheck.cc
ifdef VERBOSE
- ${filter-out -I$(newlib_source)/%,$(COMPILE_CXX)} $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) -I$(updir) $<
+ ${CXX} $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) -I$(updir) $<
else
@echo $(CXX) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) ... $^;\
- ${filter-out -I$(newlib_source)/%,$(COMPILE_CXX)} $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) -I$(updir) $<
+ ${CXX} $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) -I$(updir) $<
endif
strace.o: strace.cc
diff --git a/winsup/utils/cygcheck.cc b/winsup/utils/cygcheck.cc
index 41fb26540..b4cb93d00 100644
--- a/winsup/utils/cygcheck.cc
+++ b/winsup/utils/cygcheck.cc
@@ -1,6 +1,6 @@
/* cygcheck.cc
- Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+ Copyright 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
This file is part of Cygwin.
@@ -13,7 +13,9 @@
#include <string.h>
#include <sys/time.h>
#include <ctype.h>
+#include <io.h>
#include <windows.h>
+#include "path.h"
#include "cygwin/include/sys/cygwin.h"
#include "cygwin/include/mntent.h"
#include "cygwin/include/getopt.h"
@@ -171,7 +173,7 @@ find_on_path (char *file, char *default_extension,
static char rv[4000];
char tmp[4000], *ptr = rv;
- if (file == NULL)
+ if (!file)
{
keyeprint ("find_on_path: NULL pointer for file");
return 0;
@@ -184,7 +186,7 @@ find_on_path (char *file, char *default_extension,
}
if (strchr (file, ':') || strchr (file, '\\') || strchr (file, '/'))
- return file;
+ return cygpath (file, NULL);
if (strchr (file, '.'))
default_extension = (char *) "";
@@ -759,6 +761,74 @@ scan_registry (RegInfo * prev, HKEY hKey, char *name, int cygnus)
free (subkey_name);
}
+void
+pretty_id (const char *s, char *cygwin, size_t cyglen)
+{
+ char *groups[16384];
+
+ strcpy (cygwin + cyglen++, " ");
+ strcpy (cygwin + cyglen, s);
+ putenv (cygwin);
+
+ char *id = cygpath ("/bin/id.exe", NULL);
+ for (char *p = id; p = strchr (p, '/'); p++)
+ *p = '\\';
+
+ if (access (id, X_OK))
+ {
+ fprintf (stderr, "`id' program not found\n");
+ exit (1);
+ }
+
+ FILE *f = popen (id, "rt");
+
+ char buf[16384];
+ fgets (buf, sizeof (buf), f);
+ char *uid = strtok (buf, " ") + sizeof ("uid=") - 1;
+ char *gid = strtok (NULL, " ") + sizeof ("gid=") - 1;
+ char **ng;
+ size_t sz = 0;
+ for (ng = groups; (*ng = strtok (NULL, ",")); ng++)
+ {
+ char *p = strchr (*ng, '\n');
+ if (p)
+ *p = '\0';
+ if (ng == groups)
+ *ng += sizeof ("groups=") - 1;
+ size_t len = strlen (*ng);
+ if (sz < len)
+ sz = len;
+ }
+
+ printf ("\n%s output (%s)\n", id, s);
+ int szmaybe = sizeof ("UID: ") + strlen (uid) - 1;
+ if (sz < szmaybe)
+ sz = szmaybe;
+ sz += 1;
+ int n = 80 / (int) sz;
+ sz = -sz;
+ ng[0] += sizeof ("groups=") - 1;
+ printf ("UID: %*s GID: %s\n", sz + (sizeof ("UID: ") - 1), uid, gid);
+ int i = 0;
+ for (char **g = groups; g < ng; g++)
+ {
+ if (i < n)
+ i++;
+ else
+ {
+ i = 0;
+ puts ("");
+ }
+ if (++i <= n && g != (ng - 1))
+ printf ("%*s ", sz, *g);
+ else
+ {
+ printf ("%s\n", *g);
+ i = 0;
+ }
+ }
+}
+
static void
dump_sysinfo ()
{
@@ -878,6 +948,16 @@ dump_sysinfo ()
s = e + 1;
}
+ fflush (stdout);
+
+ char *cygwin = getenv ("CYGWIN") ?: const_cast <char *> ("CYGWIN=");
+ size_t cyglen = strlen (cygwin);
+ cygwin = strcpy ((char *) malloc (cyglen + sizeof (" nontsec")), cygwin);
+ pretty_id ("nontsec", cygwin, cyglen);
+ pretty_id ("ntsec", cygwin, cyglen);
+ cygwin[cyglen] = 0;
+ putenv (cygwin);
+
if (!GetSystemDirectory (tmp, 4000))
keyeprint ("dump_sysinfo: GetSystemDirectory()");
printf ("\nSysDir: %s\n", tmp);