Go to the source code of this file.
Data Structures | |
struct | idlist |
Functions | |
idlist * | add_list (int id, char *name) |
char * | uid_to_name (uid_t uid) |
char * | gid_to_name (gid_t gid) |
int | map_uid (int id, char *name) |
int | map_gid (int id, char *name) |
uid_t | match_uid (uid_t uid) |
gid_t | match_gid (gid_t gid) |
void | add_uid (uid_t uid) |
void | add_gid (gid_t gid) |
void | send_uid_list (int f) |
void | recv_uid_list (int f, struct file_list *flist) |
Variables | |
int | preserve_uid |
int | preserve_gid |
int | numeric_ids |
int | am_root |
idlist * | uidlist |
idlist * | gidlist |
|
Definition at line 42 of file uidlist.c. References idlist::id, idlist::name, idlist::next, out_of_memory(), and strdup(). Referenced by add_gid(), add_uid(), and recv_uid_list().
00043 { 00044 struct idlist *list = (struct idlist *)malloc(sizeof(list[0])); 00045 if (!list) out_of_memory("add_list"); 00046 list->next = NULL; 00047 list->name = strdup(name); 00048 if (!list->name) out_of_memory("add_list"); 00049 list->id = (int)id; 00050 return list; 00051 } |
|
Definition at line 56 of file uidlist.c. Referenced by add_uid().
00057 { 00058 struct passwd *pass = getpwuid(uid); 00059 if (pass) return(pass->pw_name); 00060 return NULL; 00061 } |
|
Definition at line 64 of file uidlist.c. Referenced by add_gid().
00065 { 00066 struct group *grp = getgrgid(gid); 00067 if (grp) return(grp->gr_name); 00068 return NULL; 00069 } |
|
Definition at line 71 of file uidlist.c. References name_to_uid(). Referenced by recv_uid_list().
00072 { 00073 uid_t uid; 00074 if (name_to_uid(name, &uid) && uid != 0) 00075 return uid; 00076 return id; 00077 } |
|
Definition at line 79 of file uidlist.c. References name_to_gid(). Referenced by recv_uid_list().
00080 { 00081 gid_t gid; 00082 if (name_to_gid(name, &gid) && gid != 0) 00083 return gid; 00084 return id; 00085 } |
|
Definition at line 88 of file uidlist.c. References idlist::id, idlist::id2, and idlist::next. Referenced by recv_uid_list().
00089 { 00090 static uid_t last_in, last_out; 00091 struct idlist *list = uidlist; 00092 00093 if (uid == last_in) return last_out; 00094 00095 last_in = uid; 00096 00097 while (list) { 00098 if (list->id == (int)uid) { 00099 last_out = (uid_t)list->id2; 00100 return last_out; 00101 } 00102 list = list->next; 00103 } 00104 00105 last_out = uid; 00106 return last_out; 00107 } |
|
Definition at line 109 of file uidlist.c. References idlist::id, idlist::id2, and idlist::next. Referenced by recv_uid_list().
00110 { 00111 static gid_t last_in, last_out; 00112 struct idlist *list = gidlist; 00113 00114 if (gid == last_in) return last_out; 00115 00116 last_in = gid; 00117 00118 while (list) { 00119 if (list->id == (int)gid) { 00120 last_out = (gid_t)list->id2; 00121 return last_out; 00122 } 00123 list = list->next; 00124 } 00125 00126 if (am_root) 00127 last_out = gid; 00128 else 00129 last_out = (gid_t) -1; 00130 return last_out; 00131 } |
|
Definition at line 134 of file uidlist.c. References add_list(), idlist::id, idlist::next, and uid_to_name(). Referenced by send_file_entry().
00135 { 00136 struct idlist *list = uidlist; 00137 char *name; 00138 00139 if (numeric_ids) return; 00140 00141 /* don't map root */ 00142 if (uid==0) return; 00143 00144 if (!list) { 00145 if (!(name = uid_to_name(uid))) return; 00146 uidlist = add_list((int)uid, name); 00147 return; 00148 } 00149 00150 while (list->next) { 00151 if (list->id == (int)uid) return; 00152 list = list->next; 00153 } 00154 00155 if (list->id == (int)uid) return; 00156 00157 if (!(name = uid_to_name(uid))) return; 00158 00159 list->next = add_list((int)uid, name); 00160 } |
|
Definition at line 163 of file uidlist.c. References add_list(), gid_to_name(), idlist::id, and idlist::next. Referenced by send_file_entry().
00164 { 00165 struct idlist *list = gidlist; 00166 char *name; 00167 00168 if (numeric_ids) return; 00169 00170 /* don't map root */ 00171 if (gid==0) return; 00172 00173 if (!list) { 00174 if (!(name = gid_to_name(gid))) return; 00175 gidlist = add_list((int)gid, name); 00176 return; 00177 } 00178 00179 while (list->next) { 00180 if (list->id == (int)gid) return; 00181 list = list->next; 00182 } 00183 00184 if (list->id == (int)gid) return; 00185 00186 if (!(name = gid_to_name(gid))) return; 00187 00188 list->next = add_list((int)gid, name); 00189 } |
|
Definition at line 193 of file uidlist.c. References idlist::id, idlist::name, idlist::next, write_buf(), write_byte(), and write_int(). Referenced by send_file_list().
00194 { 00195 struct idlist *list; 00196 00197 if (numeric_ids) return; 00198 00199 if (preserve_uid) { 00200 /* we send sequences of uid/byte-length/name */ 00201 list = uidlist; 00202 while (list) { 00203 int len = strlen(list->name); 00204 write_int(f, list->id); 00205 write_byte(f, len); 00206 write_buf(f, list->name, len); 00207 list = list->next; 00208 } 00209 00210 /* terminate the uid list with a 0 uid. We explicitly exclude 00211 0 from the list */ 00212 write_int(f, 0); 00213 } 00214 00215 if (preserve_gid) { 00216 list = gidlist; 00217 while (list) { 00218 int len = strlen(list->name); 00219 write_int(f, list->id); 00220 write_byte(f, len); 00221 write_buf(f, list->name, len); 00222 list = list->next; 00223 } 00224 write_int(f, 0); 00225 } 00226 } |
|
Definition at line 230 of file uidlist.c. References add_list(), am_root, file_list::count, file_list::files, file_struct::gid, idlist::id2, map_gid(), map_uid(), match_gid(), match_uid(), idlist::next, out_of_memory(), preserve_gid, preserve_uid, read_byte(), read_int(), read_sbuf(), and file_struct::uid. Referenced by recv_file_list().
00231 { 00232 int id, i; 00233 char *name; 00234 struct idlist *list; 00235 00236 if (numeric_ids) return; 00237 00238 if (preserve_uid) { 00239 /* read the uid list */ 00240 list = uidlist; 00241 id = read_int(f); 00242 while (id != 0) { 00243 int len = read_byte(f); 00244 name = (char *)malloc(len+1); 00245 if (!name) out_of_memory("recv_uid_list"); 00246 read_sbuf(f, name, len); 00247 if (!list) { 00248 uidlist = add_list(id, name); 00249 list = uidlist; 00250 } else { 00251 list->next = add_list(id, name); 00252 list = list->next; 00253 } 00254 list->id2 = map_uid(id, name); 00255 free(name); 00256 id = read_int(f); 00257 } 00258 } 00259 00260 00261 if (preserve_gid) { 00262 /* and the gid list */ 00263 list = gidlist; 00264 id = read_int(f); 00265 while (id != 0) { 00266 int len = read_byte(f); 00267 name = (char *)malloc(len+1); 00268 if (!name) out_of_memory("recv_uid_list"); 00269 read_sbuf(f, name, len); 00270 if (!list) { 00271 gidlist = add_list(id, name); 00272 list = gidlist; 00273 } else { 00274 list->next = add_list(id, name); 00275 list = list->next; 00276 } 00277 list->id2 = map_gid(id, name); 00278 free(name); 00279 id = read_int(f); 00280 } 00281 } 00282 00283 if (!(am_root && preserve_uid) && !preserve_gid) return; 00284 00285 /* now convert the uid/gid of all files in the list to the mapped 00286 uid/gid */ 00287 for (i=0;i<flist->count;i++) { 00288 if (am_root && preserve_uid && flist->files[i]->uid != 0) { 00289 flist->files[i]->uid = match_uid(flist->files[i]->uid); 00290 } 00291 if (preserve_gid && flist->files[i]->gid != 0) { 00292 flist->files[i]->gid = match_gid(flist->files[i]->gid); 00293 } 00294 } 00295 } |
|
Definition at line 28 of file uidlist.c. Referenced by parse_arguments(), and recv_uid_list(). |
|
Definition at line 29 of file uidlist.c. Referenced by parse_arguments(), and recv_uid_list(). |
|
|
|
Definition at line 31 of file uidlist.c. Referenced by recv_uid_list(). |
|
|
|
|