+Tue Mar 5 12:20:00 1996 Richard Basch <basch@lehman.com>
+
+ * kprop.c: Call krb5_sname_to_principal rather than doing the OS
+ specific calls; this also deals with site-specific hostname
+ munging that might have occurred.
+ 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
+ specific 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).
+
Wed Sep 13 23:53:19 1995 Mark Eichin <eichin@cygnus.com>
* kprop.h (KPROP_SRVTAB, KPROP_DEFAULT_FILE, KPROPD_DEFAULT_FILE,
/*
* Figure out what tickets we'll be using to send stuff
*/
- if (gethostname (my_host_name, sizeof(my_host_name)) != 0) {
- com_err(progname, errno, "while getting my hostname");
- exit(1);
+ retval = krb5_sname_to_principal(context, NULL, NULL,
+ KRB5_NT_SRV_HST, &my_principal);
+ if (retval) {
+ com_err(progname, errno, "while setting client principal name");
+ exit(1);
}
- /* get canonicalized service instance name */
- if (!(hp = gethostbyname(my_host_name))) {
- fprintf(stderr, "Couldn't get my canonicalized host name!\n");
- exit(1);
- }
- for (cp=hp->h_name; *cp; cp++)
- if (isupper(*cp))
- *cp = tolower(*cp);
- if (realm)
- sprintf(buf, "host/%s@%s", hp->h_name, realm);
- else
- sprintf(buf, "host/%s", hp->h_name);
- if (retval = krb5_parse_name(context, buf, &my_principal)) {
- com_err (progname, retval, "when parsing name %s",buf);
- exit(1);
+ if (realm) {
+ (void) krb5_xfree(krb5_princ_realm(context, my_principal)->data);
+ krb5_princ_set_realm_length(context, my_principal, strlen(realm));
+ krb5_princ_set_realm_data(context, my_principal, strdup(realm));
}
+#if 0
+ krb5_princ_type(context, my_principal) = KRB5_NT_PRINCIPAL;
+#endif
/*
* Initialize cache file which we're going to be using
* Construct the principal name for the slave host.
*/
memset((char *)&creds, 0, sizeof(creds));
- if (!(hp = gethostbyname(slave_host))) {
- fprintf(stderr,
- "Couldn't get canonicalized name for slave\n");
- exit(1);
- }
- for (cp=hp->h_name; *cp; cp++)
- if (isupper(*cp))
- *cp = tolower(*cp);
- if (!(slave_host = malloc(strlen(hp->h_name) + 1))) {
- com_err(progname, ENOMEM,
- "while allocate space for canonicalized slave host");
- exit(1);
+ retval = krb5_sname_to_principal(context,
+ slave_host, KPROP_SERVICE_NAME,
+ KRB5_NT_SRV_HST, &creds.server);
+ if (retval) {
+ com_err(progname, errno, "while setting server principal name");
+ exit(1);
}
- strcpy(slave_host, hp->h_name);
- if (realm)
- sprintf(buf, "%s/%s@%s", KPROP_SERVICE_NAME, slave_host,
- realm);
- else
- sprintf(buf, "%s/%s", KPROP_SERVICE_NAME, hp->h_name);
- if (retval = krb5_parse_name(context, buf, &creds.server)) {
- com_err(progname, retval,
- "while parsing slave principal name");
- exit(1);
+ if (realm) {
+ (void) krb5_xfree(krb5_princ_realm(context, creds.server)->data);
+ krb5_princ_set_realm_length(context, creds.server, strlen(realm));
+ krb5_princ_set_realm_data(context, creds.server, strdup(realm));
}
+
/*
* Now fill in the client....
*/
int fd;
{
int err;
- if (err = krb5_lock_file(context, fd, KRB5_LOCKMODE_UNLOCK));
+ if (err = krb5_lock_file(context, fd, KRB5_LOCKMODE_UNLOCK))
com_err(progname, err, "while unlocking database '%s'", dbpathname);
free(dbpathname);
(void)close(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);
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) {
/*
* 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);
}
/*