diff options
Diffstat (limited to 'sysutils/policykit/files/patch-tools_polkit-auth.c')
-rw-r--r-- | sysutils/policykit/files/patch-tools_polkit-auth.c | 140 |
1 files changed, 84 insertions, 56 deletions
diff --git a/sysutils/policykit/files/patch-tools_polkit-auth.c b/sysutils/policykit/files/patch-tools_polkit-auth.c index f3ee42d1f55d..3f8ad0402631 100644 --- a/sysutils/policykit/files/patch-tools_polkit-auth.c +++ b/sysutils/policykit/files/patch-tools_polkit-auth.c @@ -1,61 +1,89 @@ ---- tools/polkit-auth.c.orig 2007-12-05 22:30:18.000000000 -0500 -+++ tools/polkit-auth.c 2007-12-23 01:43:36.000000000 -0500 -@@ -37,12 +37,13 @@ +--- tools/polkit-auth.c.orig 2008-04-08 12:23:22.000000000 -0400 ++++ tools/polkit-auth.c 2008-04-22 01:24:55.000000000 -0400 +@@ -37,7 +37,7 @@ #include <stdlib.h> #include <string.h> #include <sys/types.h> -+#include <sys/wait.h> +-#ifdef HAVE_SOLARIS ++#if defined(HAVE_SOLARIS) || defined(HAVE_FREEBSD) + #include <sys/wait.h> + #endif #include <pwd.h> - #include <grp.h> - #include <unistd.h> - #include <errno.h> - #include <termios.h> +@@ -72,6 +72,77 @@ typedef struct { + GMainLoop *loop; + } UserData; - #include <polkit-dbus/polkit-dbus.h> - #include <polkit-grant/polkit-grant.h> - -@@ -107,7 +109,7 @@ conversation_select_admin_user (PolKitGr - } - printf ("\n"); - printf ("Select user: "); -- getline (&lineptr, &linelen, stdin); -+ polkit_sysdeps_getline (&lineptr, &linelen, stdin); - user = strdup (lineptr); - free (lineptr); - return user; -@@ -133,7 +135,7 @@ conversation_pam_prompt_echo_off (PolKit - exit (1); - } - -- getline (&lineptr, &linelen, stdin); -+ polkit_sysdeps_getline (&lineptr, &linelen, stdin); - - /* Restore terminal. */ - tcsetattr (fileno (stdout), TCSAFLUSH, &old); -@@ -151,7 +153,7 @@ conversation_pam_prompt_echo_on (PolKitG - size_t linelen = 0; - char *result; - printf ("%s", request); -- getline (&lineptr, &linelen, stdin); -+ polkit_sysdeps_getline (&lineptr, &linelen, stdin); - result = strdup (lineptr); - free (lineptr); - printf ("\n"); -@@ -189,7 +191,7 @@ conversation_override_grant_type (PolKit - case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION: - printf ("Keep this privilege for the session? [no/session]?\n"); - again: -- getline (&lineptr, &linelen, stdin); -+ polkit_sysdeps_getline (&lineptr, &linelen, stdin); - if (g_str_has_prefix (lineptr, "no")) { - ; - } else if (g_str_has_prefix (lineptr, "session")) { -@@ -204,7 +206,7 @@ conversation_override_grant_type (PolKit - case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS: - printf ("Keep this privilege for the session or always? [no/session/always]?\n"); - again2: -- getline (&lineptr, &linelen, stdin); -+ polkit_sysdeps_getline (&lineptr, &linelen, stdin); - if (g_str_has_prefix (lineptr, "no")) { - ; - } else if (g_str_has_prefix (lineptr, "session")) { ++#ifndef HAVE_GETLINE ++static ssize_t ++getline (char **lineptr, size_t *n, FILE *stream) ++{ ++ char *line, *p; ++ long size, copy; ++ ++ if (lineptr == NULL || n == NULL) { ++ errno = EINVAL; ++ return (ssize_t) -1; ++ } ++ ++ if (ferror (stream)) ++ return (ssize_t) -1; ++ ++ /* Make sure we have a line buffer to start with. */ ++ if (*lineptr == NULL || *n < 2) /* !seen and no buf yet need 2 chars. */ { ++#ifndef MAX_CANON ++#define MAX_CANON 256 ++#endif ++ if (!*lineptr) ++ line = (char *) malloc (MAX_CANON); ++ else ++ line = (char *) realloc (*lineptr, MAX_CANON); ++ if (line == NULL) ++ return (ssize_t) -1; ++ *lineptr = line; ++ *n = MAX_CANON; ++ } ++ ++ line = *lineptr; ++ size = *n; ++ ++ copy = size; ++ p = line; ++ ++ while (1) { ++ long len; ++ ++ while (--copy > 0) { ++ int c = getc (stream); ++ ++ if (c == EOF) ++ goto lose; ++ else if ((*p++ = c) == '\n') ++ goto win; ++ } ++ ++ /* Need to enlarge the line buffer. */ ++ len = p - line; ++ size *= 2; ++ line = (char *) realloc (line, size); ++ if (line == NULL) ++ goto lose; ++ *lineptr = line; ++ *n = size; ++ p = line + len; ++ copy = size - len; ++ } ++ ++lose: ++ if (p == *lineptr) ++ return (ssize_t) -1; ++ ++ /* Return a partial line since we got an error in the middle. */ ++win: ++ *p = '\0'; ++ return p - *lineptr; ++} ++#endif ++ + static void + conversation_type (PolKitGrant *polkit_grant, PolKitResult auth_type, void *user_data) + { |