Added the GPL notice.
[utils.git] / pam_krb5auto.c
index 6f9bc73..20b600b 100644 (file)
@@ -1,3 +1,21 @@
+/*
+ *  pam_krb5auto - Gets initial credentials non-interactively
+ *  Copyright (C) 2004 Fredrik Tolf (fredrik@dolda2000.com)
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -32,6 +50,7 @@ struct data
     krb5_creds initcreds;
     int hascreds;
     uid_t uid;
+    gid_t gid;
 };
 
 static void log(int prio, char *format, ...)
@@ -126,6 +145,7 @@ static struct data *getdata(pam_handle_t *pamh, struct options *opts)
            return(NULL);
        }
        data->uid = pwent->pw_uid;
+       data->gid = pwent->pw_gid;
        if((ret = krb5_init_context(&data->ctx)) != 0) {
            log(LOG_CRIT, "could not create krb5 context: %s", error_message(ret));
            freedata(data);
@@ -211,6 +231,7 @@ static int savecreds(pam_handle_t *pamh, struct options *opts, struct data *data
        ret = PAM_SERVICE_ERR;
        goto out;
     }
+    chown(filename, data->uid, data->gid);
     pam_putenv(pamh, strdup(buf));
     if(opts->debug)
        log(LOG_DEBUG, "successfully initialized ccache");