/*
- * $Id: afp_config.c,v 1.7.2.1 2001-12-03 05:01:03 jmarcus Exp $
+ * $Id: afp_config.c,v 1.7.2.2 2001-12-16 23:26:17 jmarcus Exp $
*
* Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
* All Rights Reserved. See COPYRIGHT.
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
/* STDC check */
#if STDC_HEADERS
SLPHandle hslp;
err = SLPOpen("en", SLP_FALSE, &hslp);
if (err != SLP_OK) {
- syslog(LOG_ERR, "Error opening SRVLOC handle");
+ syslog(LOG_ERR, "dsi_cleanup: Error opening SRVLOC handle");
goto srvloc_dereg_err;
}
SRVLOC_callback,
&callbackerr);
if (err != SLP_OK) {
- syslog(LOG_ERR, "Error unregistering %s from SRVLOC", srvloc_url);
+ syslog(LOG_ERR, "dsi_cleanup: Error unregistering %s from SRVLOC", srvloc_url);
goto srvloc_dereg_err;
}
if (callbackerr != SLP_OK) {
- syslog(LOG_ERR, "Error in callback while trying to unregister %s from SRVLOC (%i)", srvloc_url, callbackerr);
+ syslog(LOG_ERR, "dsi_cleanup: Error in callback while trying to unregister %s from SRVLOC (%d)", srvloc_url, callbackerr);
goto srvloc_dereg_err;
}
if (!(asp = asp_getsession(config->obj.handle, server_children,
config->obj.options.tickleval))) {
- syslog( LOG_ERR, "main: asp_getsession: %m" );
+ syslog( LOG_ERR, "main: asp_getsession: %s", strerror(errno) );
exit( 1 );
}
if (!(dsi = dsi_getsession(config->obj.handle, server_children,
config->obj.options.tickleval))) {
- syslog( LOG_ERR, "main: dsi_getsession: %m" );
+ syslog( LOG_ERR, "main: dsi_getsession: %s", strerror(errno) );
exit( 1 );
}
return NULL;
if ((atp = atp_open(ATADDR_ANYPORT, &options->ddpaddr)) == NULL) {
- syslog( LOG_ERR, "main: atp_open: %m");
+ syslog( LOG_ERR, "main: atp_open: %s", strerror(errno) );
free(config);
return NULL;
}
if ((asp = asp_init( atp )) == NULL) {
- syslog( LOG_ERR, "main: asp_init: %m" );
+ syslog( LOG_ERR, "main: asp_init: %s", strerror(errno) );
atp_close(atp);
free(config);
return NULL;
#endif /* USE_SRVLOC */
if ((config = (AFPConfig *) calloc(1, sizeof(AFPConfig))) == NULL) {
- syslog( LOG_ERR, "DSIConfigInit: malloc(config): %m" );
+ syslog( LOG_ERR, "DSIConfigInit: malloc(config): %s", strerror(errno) );
return NULL;
}
options->ipaddr, options->port,
options->flags & OPTION_PROXY,
options->server_quantum)) == NULL) {
- syslog( LOG_ERR, "main: dsi_init: %m" );
+ syslog( LOG_ERR, "main: dsi_init: %s", strerror(errno) );
free(config);
return NULL;
}
#ifdef USE_SRVLOC
err = SLPOpen("en", SLP_FALSE, &hslp);
if (err != SLP_OK) {
- syslog(LOG_ERR, "Error opening SRVLOC handle");
+ syslog(LOG_ERR, "DSIConfigInit: Error opening SRVLOC handle");
goto srvloc_reg_err;
}
* use a non-default port, they can, but be aware, this server might not
* show up int the Network Browser. */
afpovertcp = getservbyname("afpovertcp", "tcp");
+ if (strlen(options->hostname) > (sizeof(srvloc_url) - strlen(inet_ntoa(dsi->server.sin_addr)) - 21)) {
+ syslog(LOG_ERR, "DSIConfigInit: Hostname is too long for SRVLOC");
+ goto srvloc_reg_err;
+ }
if (dsi->server.sin_port == afpovertcp->s_port) {
- snprintf(srvloc_url, sizeof(srvloc_url), "afp://%s/?NAME=%s", inet_ntoa(dsi->server.sin_addr), options->hostname);
+ sprintf(srvloc_url, "afp://%s/?NAME=%s", inet_ntoa(dsi->server.sin_addr), options->hostname);
}
else {
- snprintf(srvloc_url, sizeof(srvloc_url), "afp://%s:%d/?NAME=%s", inet_ntoa(dsi->server.sin_addr), ntohs(dsi->server.sin_port), options->hostname);
+ sprintf(srvloc_url, "afp://%s:%d/?NAME=%s", inet_ntoa(dsi->server.sin_addr), ntohs(dsi->server.sin_port), options->hostname);
}
err = SLPReg(hslp,
SRVLOC_callback,
&callbackerr);
if (err != SLP_OK) {
- syslog(LOG_ERR, "Error registering %s with SRVLOC", srvloc_url);
+ syslog(LOG_ERR, "DSIConfigInit: Error registering %s with SRVLOC", srvloc_url);
goto srvloc_reg_err;
}
if (callbackerr != SLP_OK) {
- syslog(LOG_ERR, "Error in callback trying to register %s with SRVLOC", srvloc_url);
+ syslog(LOG_ERR, "DSIConfigInit: Error in callback trying to register %s with SRVLOC", srvloc_url);
goto srvloc_reg_err;
}
if ((refcount = (unsigned char *)
calloc(1, sizeof(unsigned char))) == NULL) {
- syslog( LOG_ERR, "AFPConfigInit: calloc(refcount): %m" );
+ syslog( LOG_ERR, "AFPConfigInit: calloc(refcount): %s", strerror(errno) );
return NULL;
}