X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fpasswd-kerberos.c;h=26b2cb869d2c08032dfad7888af726a8db940903;hb=e4fa2ac140f7bc56571373a7b7eb585fa4500e38;hp=1fbe2af9576930004241b858b0a850f60a05e4a9;hpb=2c902d6065f9856adf31e8540a94f1e42e68e905;p=xscreensaver diff --git a/driver/passwd-kerberos.c b/driver/passwd-kerberos.c index 1fbe2af9..26b2cb86 100644 --- a/driver/passwd-kerberos.c +++ b/driver/passwd-kerberos.c @@ -26,12 +26,13 @@ #include #include #include +#include /* I'm not sure if this is exactly the right test... Might __APPLE__ be defined if this is apple hardware, but not an Apple OS? - Thanks to Jan Kujawa for the MacOS X code. + Thanks to Alexei Kosut for the MacOS X code. */ #ifdef __APPLE__ # define HAVE_DARWIN @@ -161,12 +162,14 @@ kerberos_lock_init (int argc, char **argv, Bool verbose_p) we are. Calling it ive_got_your_local_function_right_here_buddy() would have been rude. */ +#ifndef HAVE_DARWIN static int key_to_key(char *user, char *instance, char *realm, char *passwd, C_Block key) { memcpy(key, passwd, sizeof(des_cblock)); return (0); } +#endif /* !HAVE_DARWIN */ /* Called to see if the user's typed password is valid. We do this by asking the kerberos server for a ticket and checking to see if it gave us one. @@ -190,6 +193,7 @@ kerberos_passwd_valid_p (const char *typed_passwd, Bool verbose_p) C_Block mitkey; Bool success; char *newtkfile; + int fh = -1; /* temporarily switch to a new ticketfile. I'm not using tmpnam() because it isn't entirely portable. @@ -197,7 +201,19 @@ kerberos_passwd_valid_p (const char *typed_passwd, Bool verbose_p) newtkfile = malloc(80 * sizeof(char)); memset(newtkfile, 0, sizeof(newtkfile)); - sprintf(newtkfile, "/tmp/xscrn-%i", getpid()); + sprintf(newtkfile, "/tmp/xscrn-%i.XXXXXX", getpid()); + + if( (fh = mkstemp(newtktfile)) < 0) + { + free(newtktfile); + return(False); + } + if( fchmod(fh, 0600) < 0) + { + free(newtktfile); + return(False); + } + krb_set_tkt_string(newtkfile); @@ -220,6 +236,7 @@ kerberos_passwd_valid_p (const char *typed_passwd, Bool verbose_p) krb_set_tkt_string(tk_file); free(newtkfile); memset(mitkey, 0, sizeof(mitkey)); + close(fh); /* #### tom: should the file be removed? */ /* Did we verify successfully? */