| 777 | */ |
| 778 | |
| 779 | const char * |
| 780 | login_getstyle(login_cap_t *lc, const char *style, const char *auth) |
| 781 | { |
| 782 | int i; |
| 783 | const char **authtypes = NULL; |
| 784 | char *auths= NULL; |
| 785 | char realauth[64]; |
| 786 | |
| 787 | static const char *defauthtypes[] = { LOGIN_DEFSTYLE, NULL }; |
| 788 | |
| 789 | if (auth != NULL && *auth != '\0') { |
| 790 | if (snprintf(realauth, sizeof realauth, "auth-%s", auth) < (int)sizeof(realauth)) |
| 791 | authtypes = login_getcaplist(lc, realauth, NULL); |
| 792 | } |
| 793 | |
| 794 | if (authtypes == NULL) |
| 795 | authtypes = login_getcaplist(lc, "auth", NULL); |
| 796 | |
| 797 | if (authtypes == NULL) |
| 798 | authtypes = defauthtypes; |
| 799 | |
| 800 | /* |
| 801 | * We have at least one authtype now; auths is a comma-separated |
| 802 | * (or space-separated) list of authentication types. We have to |
| 803 | * convert from this to an array of char*'s; authtypes then gets this. |
| 804 | */ |
| 805 | i = 0; |
| 806 | if (style != NULL && *style != '\0') { |
| 807 | while (authtypes[i] != NULL && strcmp(style, authtypes[i]) != 0) |
| 808 | i++; |
| 809 | } |
| 810 | |
| 811 | lc->lc_style = NULL; |
| 812 | if (authtypes[i] != NULL && (auths = strdup(authtypes[i])) != NULL) |
| 813 | lc->lc_style = auths; |
| 814 | |
| 815 | if (lc->lc_style != NULL) |
| 816 | lc->lc_style = strdup(lc->lc_style); |
| 817 | |
| 818 | return lc->lc_style; |
| 819 | } |
nothing calls this directly
no test coverage detected