1 /* names.c -- user/group name/id cache (plus hostname and buildtime) */
7 static uid_t uids[1024];
8 static char *unames[1024];
9 static int uid_used = 0;
11 static gid_t gids[1024];
12 static char *gnames[1024];
13 static int gid_used = 0;
16 * getUname() takes a uid, gets the username, and creates an entry in the
17 * table to hold a string containing the user name.
19 char *getUname(uid_t uid)
25 while (x < uid_used) {
32 /* XXX - This is the other hard coded limit */
34 fprintf(stderr, _("RPMERR_INTERNAL: Hit limit in getUname()\n"));
35 exit(RPMERR_INTERNAL);
42 unames[x] = strdup(pw->pw_name);
50 * getUnameS() takes a username, gets the uid, and creates an entry in the
51 * table to hold a string containing the user name.
53 char *getUnameS(char *uname)
59 while (x < uid_used) {
60 if (!strcmp(unames[x],uname)) {
66 /* XXX - This is the other hard coded limit */
68 fprintf(stderr, _("RPMERR_INTERNAL: Hit limit in getUname()\n"));
69 exit(RPMERR_INTERNAL);
76 unames[x] = strdup(pw->pw_name);
79 unames[x] = strdup(uname);
85 * getGname() takes a gid, gets the group name, and creates an entry in the
86 * table to hold a string containing the group name.
88 char *getGname(gid_t gid)
94 while (x < gid_used) {
101 /* XXX - This is the other hard coded limit */
103 fprintf(stderr, _("RPMERR_INTERNAL: Hit limit in getGname()\n"));
104 exit(RPMERR_INTERNAL);
111 gnames[x] = strdup(gr->gr_name);
119 * getGnameS() takes a group name, gets the gid, and creates an entry in the
120 * table to hold a string containing the group name.
122 char *getGnameS(char *gname)
128 while (x < gid_used) {
129 if (!strcmp(gnames[x], gname)) {
135 /* XXX - This is the other hard coded limit */
137 fprintf(stderr, _("RPMERR_INTERNAL: Hit limit in getGname()\n"));
138 exit(RPMERR_INTERNAL);
141 gr = getgrnam(gname);
144 gids[x] = gr->gr_gid;
145 gnames[x] = strdup(gr->gr_name);
148 gnames[x] = strdup(gname);
153 time_t *getBuildTime(void)
155 static time_t buildTime = 0;
158 buildTime = time(NULL);
164 char *buildHost(void)
166 static char hostname[1024];
167 static int gotit = 0;
171 gethostname(hostname, sizeof(hostname));
172 if ((hbn = gethostbyname(hostname))) {
173 strcpy(hostname, hbn->h_name);
175 rpmMessage(RPMMESS_WARNING, _("Could not canonicalize hostname: %s\n"),