Changeset View
Changeset View
Standalone View
Standalone View
pam_kwallet.c
Show First 20 Lines • Show All 383 Lines • ▼ Show 20 Line(s) | 381 | for (; x < 64; ++x) { | |||
---|---|---|---|---|---|
384 | } | 384 | } | ||
385 | } | 385 | } | ||
386 | 386 | | |||
387 | //This is the side of the pipe PAM will send the hash to | 387 | //This is the side of the pipe PAM will send the hash to | ||
388 | close (toWalletPipe[1]); | 388 | close (toWalletPipe[1]); | ||
389 | 389 | | |||
390 | //Change to the user in case we are not it yet | 390 | //Change to the user in case we are not it yet | ||
391 | if (drop_privileges(userInfo) < 0) { | 391 | if (drop_privileges(userInfo) < 0) { | ||
392 | syslog(LOG_ERR, "%s: could not set gid/uid/euid/egit for kwalletd", logPrefix); | 392 | syslog(LOG_ERR, "%s: could not set gid/uid/euid/egit for kwalletd", logPrefix); | ||
393 | free(fullSocket); | ||||
anthonyfieroni: fullSocket is not free'd. | |||||
393 | goto cleanup; | 394 | goto cleanup; | ||
394 | } | 395 | } | ||
395 | 396 | | |||
396 | int envSocket; | 397 | int envSocket; | ||
397 | if ((envSocket = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { | 398 | if ((envSocket = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { | ||
398 | pam_syslog(pamh, LOG_ERR, "%s: couldn't create socket", logPrefix); | 399 | syslog(LOG_ERR, "%s: couldn't create socket", logPrefix); | ||
399 | return; | 400 | free(fullSocket); | ||
401 | goto cleanup; | ||||
anthonyfieroni: Here also. | |||||
400 | } | 402 | } | ||
401 | 403 | | |||
402 | struct sockaddr_un local; | 404 | struct sockaddr_un local; | ||
403 | local.sun_family = AF_UNIX; | 405 | local.sun_family = AF_UNIX; | ||
404 | 406 | | |||
405 | if (strlen(fullSocket) > sizeof(local.sun_path)) { | 407 | if (strlen(fullSocket) > sizeof(local.sun_path)) { | ||
406 | pam_syslog(pamh, LOG_ERR, "%s: socket path %s too long to open", | 408 | syslog(LOG_ERR, "%s: socket path %s too long to open", | ||
407 | logPrefix, fullSocket); | 409 | logPrefix, fullSocket); | ||
408 | free(fullSocket); | 410 | free(fullSocket); | ||
409 | return; | 411 | goto cleanup; | ||
410 | } | 412 | } | ||
411 | strcpy(local.sun_path, fullSocket); | 413 | strcpy(local.sun_path, fullSocket); | ||
412 | free(fullSocket); | 414 | free(fullSocket); | ||
413 | fullSocket = NULL; | 415 | fullSocket = NULL; | ||
414 | unlink(local.sun_path);//Just in case it exists from a previous login | 416 | unlink(local.sun_path);//Just in case it exists from a previous login | ||
415 | 417 | | |||
416 | pam_syslog(pamh, LOG_INFO, "%s: final socket path: %s", logPrefix, local.sun_path); | 418 | syslog(LOG_INFO, "%s: final socket path: %s", logPrefix, local.sun_path); | ||
417 | 419 | | |||
418 | size_t len = strlen(local.sun_path) + sizeof(local.sun_family); | 420 | size_t len = strlen(local.sun_path) + sizeof(local.sun_family); | ||
419 | if (bind(envSocket, (struct sockaddr *)&local, len) == -1) { | 421 | if (bind(envSocket, (struct sockaddr *)&local, len) == -1) { | ||
420 | pam_syslog(pamh, LOG_INFO, "%s-kwalletd: Couldn't bind to local file\n", logPrefix); | 422 | syslog(LOG_INFO, "%s-kwalletd: Couldn't bind to local file\n", logPrefix); | ||
421 | return; | 423 | goto cleanup; | ||
422 | } | 424 | } | ||
423 | 425 | | |||
424 | if (listen(envSocket, 5) == -1) { | 426 | if (listen(envSocket, 5) == -1) { | ||
425 | pam_syslog(pamh, LOG_INFO, "%s-kwalletd: Couldn't listen in socket\n", logPrefix); | 427 | syslog(LOG_INFO, "%s-kwalletd: Couldn't listen in socket\n", logPrefix); | ||
426 | return; | 428 | goto cleanup; | ||
427 | } | 429 | } | ||
428 | //finally close stderr | 430 | //finally close stderr | ||
429 | close(2); | 431 | close(2); | ||
430 | 432 | | |||
431 | // Fork twice to daemonize kwallet | 433 | // Fork twice to daemonize kwallet | ||
432 | setsid(); | 434 | setsid(); | ||
433 | pid_t pid = fork(); | 435 | pid_t pid = fork(); | ||
434 | if (pid != 0) { | 436 | if (pid != 0) { | ||
▲ Show 20 Lines • Show All 343 Lines • Show Last 20 Lines |
fullSocket is not free'd.