Home | History | Annotate | Download | only in bionic

Lines Matching refs:state

55 // okay for all the <grp.h> functions to share state, and all the <passwd.h>
56 // functions to share state, but <grp.h> functions can't clobber <passwd.h>
57 // functions' state and vice versa.
67 static void init_group_state(group_state_t* state) {
68 memset(state, 0, sizeof(group_state_t) - sizeof(state->getgrent_idx));
69 state->group_.gr_mem = state->group_members_;
140 static passwd* android_iinfo_to_passwd(passwd_state_t* state,
142 snprintf(state->name_buffer_, sizeof(state->name_buffer_), "%s", iinfo->name);
143 snprintf(state->dir_buffer_, sizeof(state->dir_buffer_), "/");
144 snprintf(state->sh_buffer_, sizeof(state->sh_buffer_), "/system/bin/sh");
146 passwd* pw = &state->passwd_;
147 pw->pw_name = state->name_buffer_;
150 pw->pw_dir = state->dir_buffer_;
151 pw->pw_shell = state->sh_buffer_;
155 static group* android_iinfo_to_group(group_state_t* state,
157 snprintf(state->group_name_buffer_, sizeof(state->group_name_buffer_), "%s", iinfo->name);
159 group* gr = &state->group_;
160 gr->gr_name = state->group_name_buffer_;
166 static passwd* android_id_to_passwd(passwd_state_t* state, unsigned id) {
169 return android_iinfo_to_passwd(state, android_ids + n);
175 static passwd* android_name_to_passwd(passwd_state_t* state, const char* name) {
178 return android_iinfo_to_passwd(state, android_ids + n);
184 static group* android_id_to_group(group_state_t* state, unsigned id) {
187 return android_iinfo_to_group(state, android_ids + n);
193 static group* android_name_to_group(group_state_t* state, const char* name) {
196 return android_iinfo_to_group(state, android_ids + n);
427 static passwd* oem_id_to_passwd(uid_t uid, passwd_state_t* state) {
432 if (vendor_passwd.FindById(uid, state)) {
433 return &state->passwd_;
436 snprintf(state->name_buffer_, sizeof(state->name_buffer_), "oem_%u", uid);
437 snprintf(state->dir_buffer_, sizeof(state->dir_buffer_), "/");
438 snprintf(state->sh_buffer_, sizeof(state->sh_buffer_), "/system/bin/sh");
440 passwd* pw = &state->passwd_;
441 pw->pw_name = state->name_buffer_;
442 pw->pw_dir = state->dir_buffer_;
443 pw->pw_shell = state->sh_buffer_;
449 static group* oem_id_to_group(gid_t gid, group_state_t* state) {
454 if (vendor_group.FindById(gid, state)) {
455 return &state->group_;
458 snprintf(state->group_name_buffer_, sizeof(state->group_name_buffer_),
461 group* gr = &state->group_;
462 gr->gr_name = state->group_name_buffer_;
474 static passwd* app_id_to_passwd(uid_t uid, passwd_state_t* state) {
480 print_app_name_from_uid(uid, state->name_buffer_, sizeof(state->name_buffer_));
484 snprintf(state->dir_buffer_, sizeof(state->dir_buffer_), "/");
486 snprintf(state->dir_buffer_, sizeof(state->dir_buffer_), "/data");
489 snprintf(state->sh_buffer_, sizeof(state->sh_buffer_), "/system/bin/sh");
491 passwd* pw = &state->passwd_;
492 pw->pw_name = state->name_buffer_;
493 pw->pw_dir = state->dir_buffer_;
494 pw->pw_shell = state->sh_buffer_;
502 static group* app_id_to_group(gid_t gid, group_state_t* state) {
508 print_app_name_from_gid(gid, state->group_name_buffer_, sizeof(state->group_name_buffer_));
510 group* gr = &state->group_;
511 gr->gr_name = state->group_name_buffer_;
518 passwd_state_t* state = get_passwd_tls_buffer();
519 if (state == NULL) {
523 passwd* pw = android_id_to_passwd(state, uid);
528 pw = oem_id_to_passwd(uid, state);
532 return app_id_to_passwd(uid, state);
536 passwd_state_t* state = get_passwd_tls_buffer();
537 if (state == NULL) {
541 passwd* pw = android_name_to_passwd(state, login);
546 if (vendor_passwd.FindByName(login, state)) {
547 if (is_oem_id(state->passwd_.pw_uid)) {
548 return &state->passwd_;
553 pw = oem_id_to_passwd(oem_id_from_name(login), state);
557 return app_id_to_passwd(app_id_from_name(login, false), state);
585 passwd_state_t* state = get_passwd_tls_buffer();
586 if (state) {
587 state->getpwent_idx = 0;
596 passwd_state_t* state = get_passwd_tls_buffer();
597 if (state == NULL) {
600 if (state->getpwent_idx < 0) {
606 if (state->getpwent_idx < end) {
607 return android_iinfo_to_passwd(state, android_ids + state->getpwent_idx++);
613 if (state->getpwent_idx < end) {
615 state->getpwent_idx++ - start + AID_OEM_RESERVED_START, state);
621 if (state->getpwent_idx < end) {
623 state->getpwent_idx++ - start + AID_OEM_RESERVED_2_START, state);
626 state->getpwent_idx = get_next_app_id(state->getpwent_idx);
628 if (state->getpwent_idx != -1) {
629 return app_id_to_passwd(state->getpwent_idx, state);
636 static group* getgrgid_internal(gid_t gid, group_state_t* state) {
637 group* grp = android_id_to_group(state, gid);
642 grp = oem_id_to_group(gid, state);
646 return app_id_to_group(gid, state);
650 group_state_t* state = __group_state();
651 if (state == NULL) {
654 return getgrgid_internal(gid, state);
657 static group* getgrnam_internal(const char* name, group_state_t* state) {
658 group* grp = android_name_to_group(state, name);
663 if (vendor_group.FindByName(name, state)) {
664 if (is_oem_id(state->group_.gr_gid)) {
665 return &state->group_;
670 grp = oem_id_to_group(oem_id_from_name(name), state);
674 return app_id_to_group(app_id_from_name(name, true), state);
678 group_state_t* state = __group_state();
679 if (state == NULL) {
682 return getgrnam_internal(name, state);
694 group_state_t* state = reinterpret_cast<group_state_t*>(p);
695 init_group_state(state);
696 group* retval = (by_name ? getgrnam_internal(name, state) : getgrgid_internal(gid, state));
715 group_state_t* state = get_group_tls_buffer();
716 if (state) {
717 state->getgrent_idx = 0;
726 group_state_t* state = get_group_tls_buffer();
727 if (state == NULL) {
730 if (state->getgrent_idx < 0) {
736 if (state->getgrent_idx < end) {
737 init_group_state(state);
738 return android_iinfo_to_group(state, android_ids + state->getgrent_idx++);
744 if (state->getgrent_idx < end) {
745 init_group_state(state);
747 state->getgrent_idx++ - start + AID_OEM_RESERVED_START, state);
753 if (state->getgrent_idx < end) {
754 init_group_state(state);
756 state->getgrent_idx++ - start + AID_OEM_RESERVED_2_START, state);
762 state->getgrent_idx = get_next_app_id(state->getgrent_idx);
764 if (state->getgrent_idx != -1) {
765 return app_id_to_group(state->getgrent_idx, state);