From 66b60913edde7f4585f23955c804abf2117f881f Mon Sep 17 00:00:00 2001 From: Richard Basch Date: Tue, 5 Mar 1996 17:31:01 +0000 Subject: * kprop.c: Call krb5_sname_to_principal rather than doing the OS calls. Removed a trailing ; that caused a spurious message to be printed even upon success. * kpropd.c: Call krb5_sname_to_principal rather than doing the OS calls. Open the lock file read-write, as required by POSIX. Downgrade the lock to a shared lock prior to the execution of kdb5_edit (it also tries to place a shared lock on the dump file). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7595 dc483132-0cff-0310-8789-dd5450dbe970 --- src/slave/kpropd.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'src/slave/kpropd.c') diff --git a/src/slave/kpropd.c b/src/slave/kpropd.c index 7258d7c89..75e21fde2 100644 --- a/src/slave/kpropd.c +++ b/src/slave/kpropd.c @@ -279,7 +279,7 @@ void doit(fd) exit(1); } omask = umask(077); - lock_fd = open(temp_file_name, O_RDONLY, 0600); + lock_fd = open(temp_file_name, O_RDWR|O_CREAT, 0600); (void) umask(omask); retval = krb5_lock_file(kpropd_context, lock_fd, KRB5_LOCKMODE_EXCLUSIVE|KRB5_LOCKMODE_DONTBLOCK); @@ -306,6 +306,12 @@ void doit(fd) temp_file_name, file); exit(1); } + retval = krb5_lock_file(kpropd_context, lock_fd, KRB5_LOCKMODE_SHARED); + if (retval) { + com_err(progname, retval, "while downgrading lock on '%s'", + temp_file_name); + exit(1); + } load_database(kpropd_context, kdb5_edit, file); retval = krb5_lock_file(kpropd_context, lock_fd, KRB5_LOCKMODE_UNLOCK); if (retval) { @@ -430,25 +436,12 @@ void PRS(argv) /* * Get my hostname, so we can construct my service name */ - if (gethostname (my_host_name, sizeof(my_host_name)) != 0) { - com_err(progname, errno, "while getting my hostname"); - exit(1); - } - if (!(hp = gethostbyname(my_host_name))) { - fprintf(stderr, "Couldn't get my cannonicalized host name!\n"); - exit(1); - } - for (cp=hp->h_name; *cp; cp++) - if (isupper(*cp)) - *cp = tolower(*cp); - if (realm) - sprintf(buf, "%s/%s@%s", KPROP_SERVICE_NAME, hp->h_name, - realm); - else - sprintf(buf, "%s/%s", KPROP_SERVICE_NAME, hp->h_name); - if (retval = krb5_parse_name(kpropd_context, buf, &server)) { + retval = krb5_sname_to_principal(kpropd_context, + NULL, KPROP_SERVICE_NAME, + KRB5_NT_SRV_HST, &server); + if (retval) { com_err(progname, retval, - "While trying to parse %s for service name"); + "While trying to construct my service name"); exit(1); } /* -- cgit