/* This software is licensed under GPL-3, as shown in the file LICENSE Author: Linux Gruppe IRB Copyright: Linux Gruppe IRB, 2024 */ #include #include #include #include #include #include #include #include #include "authorized_eid.h" #include "client.h" #include "json.h" int main(int argc, char *argv[]) { struct passwd *passwd; FILE *authorized_eid; char *res1, *res2; gchar *hash; CURL *curl; if ((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed"); exit(-1); } port = 24727; res1 = eidResponse(curl); if (res1 == NULL) { fprintf(stderr, "Did not receive a valid result from the web\n"); exit(-2); } res2 = json2txt(res1); if (res2 == NULL) { fprintf(stderr, "The result from the web could not be parsed\n"); exit(-3); } hash = g_compute_checksum_for_string(G_CHECKSUM_SHA512, res2, strlen(res2)); free(res2); errno = 0; if ((passwd = getpwuid(geteuid())) == NULL) { fprintf(stderr, "Error while trying to find passwd entry for effective UID %u: ", geteuid()); if (errno != 0) fprintf(stderr, "%s\n", strerror(errno)); else fprintf(stderr, "No such user\n"); exit(-3); } if ((authorized_eid = auth_fopen(passwd, "a")) == NULL) { fprintf(stderr, "Could not open german eID card data file for writing\n"); exit(-4); } fchmod(fileno(authorized_eid), S_IRUSR | S_IWUSR); fprintf(authorized_eid, "%s\n", hash); fclose(authorized_eid); }