static gboolean mk_chown(struct rdup *e, GHashTable * uidhash, GHashTable * gidhash) { uid_t u; gid_t g; u = lookup_uid(uidhash, e->f_user, e->f_uid); g = lookup_gid(gidhash, e->f_group, e->f_gid); if (lchown(e->f_name, u, g) == -1) { if (opt_chown) { /* chown failed, use and create ._rdup_. - file, it that fails too * we're out of luck - so we don't care about the return value */ if (S_ISDIR(e->f_mode)) { chown_write(e->f_name, NULL, e->f_uid, e->f_user, e->f_gid, e->f_group); } else { chown_write(dirname(e->f_name), basename(e->f_name), e->f_uid, e->f_user, e->f_gid, e->f_group); } } else { if (!opt_quiet) { msgd(__func__, __LINE__, _("Failed to chown `%s\': %s"), e->f_name, strerror(errno)); } } } return TRUE; }
bool passwd_cache::lookup_uid_entry( const char* user, uid_entry *&uce ) { if( !lookup_uid( user, uce) ) { /* CACHE MISS */ if( cache_uid(user) ) { if( !lookup_uid(user, uce) ) { dprintf( D_ALWAYS, "Failed to cache user info for user %s\n", user ); return false; } } else { // cache_user() failure. Not much we can do there. return false; } } return true; }
static BI_NODE * new_node(void *data) { UID_DATA *value = (UID_DATA *) data; BI_NODE *result = BI_NODE_ALLOC(sizeof(UID_DATA)); memset(result, 0, sizeof(*result)); value->name = lookup_uid(value->user); memcpy((char *) &(result->value), (char *) data, sizeof(UID_DATA)); return result; }
/* For testing purposes only */ int passwd_cache::get_uid_entry_age(const char *user) { uid_entry *uce; if ( !lookup_uid(user, uce) ) { return -1; } else { return (time(NULL) - uce->lastupdated); } }