aboutsummaryrefslogtreecommitdiffstats
path: root/lang/tclX/files/patch-uidgid
blob: c5ef9187f9de119f94a26a19be2a821e1a2ee9b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
--- unix/tclXunixId.c   Thu Dec  2 22:02:08 1999
+++ unix/tclXunixId.c   Fri Jan 10 17:36:50 2003
@@ -41,3 +41,3 @@
 UseridToUsernameResult _ANSI_ARGS_((Tcl_Interp *interp,
-                                    int         userId));
+                                    long        userId));
 
@@ -49,3 +49,3 @@
 GroupidToGroupnameResult _ANSI_ARGS_((Tcl_Interp *interp,
-                                      int         groupId));
+                                      long        groupId));
 
@@ -149,13 +149,13 @@
 static int
 UseridToUsernameResult (interp, userId)
     Tcl_Interp *interp;
-    int         userId;
+    long        userId;
 {
-    uid_t          uid = (uid_t) userId;
-    struct passwd *pw = getpwuid (userId);
+    uid_t          uid = (uid_t)userId;
+    struct passwd *pw;
     Tcl_Obj       *resultObj = Tcl_GetObjResult (interp);
-    char          userIdString[16];
 
-    if ((pw == NULL) || ((int) uid != userId)) {
-   sprintf (userIdString, "%d", uid);
+    if ((long)uid != userId || (pw = getpwuid(uid)) == NULL) {
+   char    userIdString[32];
+   sprintf (userIdString, "%ld", userId);
    Tcl_AppendStringsToObj (resultObj, 
@@ -188,3 +188,3 @@
     }
-    Tcl_SetObjResult (interp, Tcl_NewIntObj (pw->pw_uid));
+    Tcl_SetObjResult (interp, Tcl_NewIntObj ((int)pw->pw_uid));
     endpwent ();
@@ -194,14 +194,13 @@
 static int
 GroupidToGroupnameResult (interp, groupId)
     Tcl_Interp *interp;
-    int         groupId;
+    long        groupId;
 {
-    gid_t          gid = (gid_t) groupId;
-    struct group  *grp = getgrgid (groupId);
+    gid_t gid = (gid_t)groupId;
+    struct group  *grp = getgrgid (gid);
     Tcl_Obj       *resultObj = Tcl_GetObjResult (interp);
-    char          groupIdString[16];
-
-    sprintf (groupIdString, "%d", gid);
 
-    if ((grp == NULL) || ((int) gid != groupId)) {
+    if ((long)gid != groupId || (grp = getgrgid (gid)) == NULL) {
+   char    groupIdString[32];
+   sprintf (groupIdString, "%ld", groupId);
    Tcl_AppendStringsToObj (resultObj, 
@@ -232,3 +231,3 @@
     }
-    Tcl_SetIntObj (resultObj, grp->gr_gid);
+    Tcl_SetLongObj (resultObj, (long)grp->gr_gid);
     return TCL_OK;
@@ -297,6 +296,6 @@
     if (STREQU (subCommand, "user"))
-        return UseridToUsernameResult (interp, geteuid ());
+        return UseridToUsernameResult (interp, (long)geteuid ());
     
     if (STREQU (subCommand, "userid")) {
-   Tcl_SetObjResult (interp, Tcl_NewIntObj (geteuid ()));
+   Tcl_SetObjResult (interp, Tcl_NewLongObj ((long)geteuid ()));
         return TCL_OK;
@@ -305,6 +304,6 @@
     if (STREQU (subCommand, "group"))
-        return GroupidToGroupnameResult (interp, getegid ());
+        return GroupidToGroupnameResult (interp, (long)getegid ());
     
     if (STREQU (subCommand, "groupid")) {
-   Tcl_SetObjResult (interp, Tcl_NewIntObj (getegid ()));
+   Tcl_SetObjResult (interp, Tcl_NewLongObj ((long)getegid ()));
         return TCL_OK;
@@ -419,3 +418,3 @@
         if (symbolic) {
-       int    groupId = groups [groupIndex];
+       gid_t groupId = groups [groupIndex];
             grp = getgrgid (groupId);
@@ -437,3 +436,3 @@
         } else {
-       newObj = Tcl_NewIntObj(groups[groupIndex]);
+       newObj = Tcl_NewLongObj((long)groups[groupIndex]);
             Tcl_ListObjAppendElement (interp, 
@@ -514,3 +513,3 @@
     if (objc == 2) {
-        return UseridToUsernameResult (interp, getuid ());
+        return UseridToUsernameResult (interp, (long)getuid ());
     }
@@ -552,3 +551,3 @@
     if (objc == 2) {
-   Tcl_SetObjResult (interp, Tcl_NewIntObj (getuid()));
+   Tcl_SetObjResult (interp, Tcl_NewLongObj ((long)getuid()));
         return TCL_OK;
@@ -583,3 +582,3 @@
     if (objc == 2) {
-        return GroupidToGroupnameResult (interp, getgid ());
+        return GroupidToGroupnameResult (interp, (long)getgid ());
     }
@@ -621,3 +620,3 @@
     if (objc == 2) {
-   Tcl_SetIntObj (Tcl_GetObjResult (interp), getgid());
+   Tcl_SetObjResult (interp, Tcl_NewLongObj((long)getgid()));
         return TCL_OK;