* details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with these librararies and programs; if not, write
+ * License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
#ifdef _AIX
#ifdef _POWER
#include <stdio.h>
+#include <errno.h>
#include <sys/file.h>
#endif /* _POWER */
# include <usersec.h>
# include <signal.h>
# include <X11/Xatom.h>
# include <setjmp.h>
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) && OSMAJORVERSION > 8
# include <utmpx.h>
#else
# include <utmp.h>
#endif /* SIA */
-
-#ifdef __apollo
- extern char *getenv();
-#endif
-
#define GREET_STATE_LOGIN 0
#define GREET_STATE_AUTHENTICATE 1
#define GREET_STATE_EXIT 2
longjmp (pingTime, 1);
}
-static int
-FileNameCompare (a, b)
#if defined(__STDC__)
- const void *a, *b;
+static int
+FileNameCompare (const char *a, const char *b)
#else
- char *a, *b;
+static int
+FileNameCompare (char *a, char *b)
#endif
{
return strcoll (*(char **)a, *(char **)b);
IOErrorHandler( Display *dpy )
{
- char *s = ((errno >= 0 && errno < sys_nerr) ? sys_errlist[errno]
- : "unknown error");
+ const char *s = strerror(errno);
LogError(ReadCatalog(
MC_LOG_SET,MC_LOG_FATAL_IO,MC_DEF_LOG_FATAL_IO),
LoadXloginResources( struct display *d )
{
char cmd[1024];
- char *language="";
- char *lang_key="";
char *authority="";
char *auth_key="";
char *resources = NULL;
if (access (resources, R_OK) != 0) {
/** fallback to the C locale for resources **/
Debug("LoadXloginResources - cant access %s\n", resources);
- Debug("\t %s. Falling back to C.\n", sys_errlist[errno]);
+ Debug("\t %s. Falling back to C.\n", strerror(errno));
free(resources);
resources = _ExpandLang(d->resources, "C");
if (access (resources, R_OK) != 0) {
/** can't find a resource file, so bail **/
Debug("LoadXloginResources - cant access %s.\n", resources);
Debug("\t %s. Unable to find resource file.\n",
- sys_errlist[errno]);
+ strerror(errno));
free(resources);
return(-1);
}
auth_key = "XAUTHORITY=";
}
- if (d->language && strlen(d->language) > 0 ) {
- language = strdup(d->language);
- lang_key = "-D";
- }
-
- /*
- * replace any "-" or "." in the language name with "_". The C
- * preprocessor used by xrdb does not accept "-" or "." in a name.
- */
-
- while ( (p = strchr(language, '-')) != NULL ) {
- *p = '_';
- }
-
- while ( (p = strchr(language, '.')) != NULL ) {
- *p = '_';
- }
-
- if ( strlen(language) > 0 )
- free(language);
-
-
Debug("LoadXloginResources - loading resource db from %s\n", resources);
if((XresourceDB = XrmGetFileDatabase(resources)) == NULL)
Debug("LoadXloginResources - Loading resource db from %s failed\n",
auth_key, authority, d->xrdb, d->name, tmpname);
Debug ("Loading resource file: %s\n", cmd);
- system (cmd);
+ if(-1 == system (cmd)) {
+ Debug ("system() failed on cmd '%s'\n", cmd);
+ return -1;
+ }
if (debugLevel <= 10)
if (unlink (tmpname) == -1)
if ( XrmGetResource(XresourceDB,
"Dtlogin*altDts", "Dtlogin*AltDts",
&rmtype, &rmvalue ) ) {
- strcpy(tempbuf,rmvalue.addr);
+ snprintf(tempbuf, sizeof(tempbuf), "%s", rmvalue.addr);
i = atoi(tempbuf);
}
if (access (resources, R_OK) != 0)
{
Debug("LoadAltDtsResources- cant access %s.\n", resources);
- Debug("\t %s. Falling back to C.\n", sys_errlist[errno]);
+ Debug("\t %s. Falling back to C.\n", strerror(errno));
- if (resources)
- {
- free (resources);
- resources = NULL;
- }
+ free (resources);
+ resources = NULL;
resources = _ExpandLang(dirname[j], "C");
if (access (resources, R_OK) != 0)
{
Debug("LoadAltDtsResources- cant access %s.\n", resources);
- Debug("\t %s.\n", sys_errlist[errno]);
+ Debug("\t %s.\n", strerror(errno));
}
else
- strcpy(dirname[j], resources);
+ snprintf(dirname[j], sizeof(dirname[j]), "%s", resources);
}
else {
- strcpy(dirname[j],resources);
+ snprintf(dirname[j], sizeof(dirname[j]), "%s", resources);
Debug("LoadAltDtsResources- found resource dir %s\n", dirname[j]);
}
- if (resources)
- {
- free (resources);
- resources = NULL;
- }
+ free (resources);
+ resources = NULL;
}
{
Debug("LoadAltDtsResources- cant access %s.\n",
resources);
- Debug("\t %s.\n", sys_errlist[errno]);
+ Debug("\t %s.\n", strerror(errno));
continue;
}
if (file_count == 0) {
- file_list = malloc (list_incr * sizeof(char **));
+ file_list = malloc (list_incr * sizeof(char *));
num_allocated += list_incr;
}
if (file_count + 1 > num_allocated) {
num_allocated += list_incr;
file_list = realloc (file_list,
- num_allocated * sizeof(char **));
+ num_allocated * sizeof(char *));
}
file_list[file_count] = strdup (res_file);
file_count++;
* remove the trailing spaces
*/
if(strchr(rmvalue.addr,' '))
- strcpy(tempbuf, strtok(rmvalue.addr," "));
+ snprintf(tempbuf, sizeof(tempbuf), "%s", strtok(rmvalue.addr," "));
else
- strcpy(tempbuf, rmvalue.addr);
+ snprintf(tempbuf, sizeof(tempbuf), "%s", rmvalue.addr);
if ((strcmp(tempbuf, "True") == 0) ||
(strcmp(tempbuf, "TRUE") == 0)) {
/* make sure the server gets reset after the session is over */
if (d->serverPid >= 2) {
- Debug("Reseting server: pid %d signal %d\n",
+ Debug("Resetting server: pid %d signal %d\n",
d->serverPid, d->resetSignal);
if (d->terminateServer == 0 && d->resetSignal)
Debug("BLS - Session setup complete.\n");
} else {
#endif /* BLS */
-
-#ifdef __apollo
-
- /*
- * This should never fail since everything has been verified already.
- * If it does it must mean registry strangeness, so exit, and try
- * again...
- */
-
- if (!DoLogin (user, greet.password, d->name)) exit (1);
-
- /*
- * extract the SYSTYPE and ISP environment values and set into user's
- * environment. This is necessary since we do an execve below...
- */
-
- verify->userEnviron = setEnv(verify->userEnviron, "SYSTYPE",
- getenv("SYSTYPE"));
-
- verify->userEnviron = setEnv(verify->userEnviron, "ISP",
- getenv("ISP"));
-
-#else /* ! __apollo */
-
# ifdef __AFS
if ( IsVerifyName(VN_AFS) ) {
* the "setgroups()" call instead...
*/
-# if (defined(__hpux) || defined(__osf__))
+# if defined(__hpux)
initgroups(user, -1);
# else
setgroups (verify->ngroups, verify->groups);
/* setpenv() will set gid for AIX */
#if !defined (_AIX)
- setgid (verify->groups[0]);
+ if(-1 == setgid (verify->groups[0])) {
+ perror(strerror(errno));
+ }
#endif
# else /* ! NGROUPS */
}
#endif
-#endif /* __apollo */
-
#ifdef BLS
} /* ends the else clause of if ( ISSECURE ) */
#endif /* BLS */
LogError (ReadCatalog(
MC_LOG_SET,MC_LOG_NO_HMDIR,MC_DEF_LOG_NO_HMDIR),
home, getEnv (verify->userEnviron, "USER"));
- chdir ("/");
+ if(-1 == chdir ("/")) {
+ perror(strerror(errno));
+ }
verify->userEnviron = setEnv(verify->userEnviron,
"HOME", "/");
}
failsafeArgv[i++] = "/usr/bin/X11/aixterm";
#elif defined(sun)
failsafeArgv[i++] = "/usr/openwin/bin/xterm";
-#elif defined (USL) || defined(__uxp__)
- failsafeArgv[i++] = "/usr/X/bin/xterm";
#elif defined(__hpux)
failsafeArgv[i++] = "/usr/bin/X11/hpterm";
+#elif defined(__OpenBSD__)
+ failsafeArgv[i++] = "/usr/X11R6/bin/xterm";
+#elif defined(__NetBSD__)
+ failsafeArgv[i++] = "/usr/X11R7/bin/xterm";
+#elif defined(__FreeBSD__)
+ failsafeArgv[i++] = "/usr/local/bin/xterm";
#else
failsafeArgv[i++] = "/usr/bin/X11/xterm";
#endif
failsafeArgv[i++] = "-e";
failsafeArgv[i++] = "/bin/passwd";
-#if defined (__apollo) || defined(__PASSWD_ETC)
+#if defined(__PASSWD_ETC)
failsafeArgv[i++] = "-n";
#endif
failsafeArgv[i++] = getEnv (verify->userEnviron, "USER");
MC_LOG_SET,MC_LOG_NO_KILLCL,MC_DEF_LOG_NO_KILLCL));
case EINVAL:
case ESRCH:
- return;
+ return 0;
}
}
if (!setjmp (tenaciousClient)) {
signal (SIGALRM, SIG_DFL);
sig = SIGKILL;
}
+ return 1;
}
int
return 0;
}
+/* returns 0 on failure, -1 on out of mem, and 1 on success */
int
execute(char **argv, char **environ )
{
*/
f = fopen (argv[0], "r");
if (!f)
- return;
+ return 0;
if (fgets (program, sizeof (program) - 1, f) == NULL)
{
fclose (f);
- return;
+ return 0;
}
fclose (f);
e = program + strlen (program) - 1;
;
session_execve (newargv[0], newargv, environ);
}
+
+ return 1;
}
char *path;
struct greet_state state;
int notify_dt;
+ int dupfp = -1;
+ int dupfp2 = -1;
#ifdef __PASSWD_ETC
# ifndef U_NAMELEN
* set up communication pipes...
*/
- pipe(response);
- pipe(request);
+ if(-1 == pipe(response)) {
+ perror(strerror(errno));
+ }
+ if(-1 == pipe(request)) {
+ perror(strerror(errno));
+ }
rbytes = 0;
if((path = getenv("NLSPATH")) != NULL)
env = setEnv(env, "NLSPATH", path);
-#ifdef __hp_osf
- env = setEnv(env, "NLSPATH", "/usr/lib/nls/msg/%L/%N.cat");
-#endif
/*
if ( d->langList && strlen(d->langList) > 0 )
env = setEnv(env, LANGLIST, d->langList);
#if !defined (ENABLE_DYNAMIC_LANGLIST)
- else if (languageList && strlen(languageList) > 0 )
+ else if (strlen(languageList) > 0 )
env = setEnv(env, LANGLIST, languageList);
#endif /* ENABLE_DYNAMIC_LANGLIST */
language = d->language;
#endif /* ENABLE_DYNAMIC_LANGLIST */
- if ( d->language && strlen(d->language) > 0 )
+ if (env && d->language && strlen(d->language) > 0 )
env = setLang(d, env, language);
}
env = setEnv(env, "OPENWINHOME", path);
#endif
-#ifdef __apollo
- /*
- * set environment for Domain machines...
- */
- env = setEnv(env, "ENVIRONMENT", "bsd");
- env = setEnv(env, "SYSTYPE", "bsd4.3");
-#endif
-
-
Debug ("Greeter environment:\n");
printEnv(env);
Debug ("End of Greeter environment:\n");
* Writing to file descriptor 1 goes to response pipe instead.
*/
close(1);
- dup(response[1]);
+ dupfp = dup(response[1]);
+ if(-1 == dupfp) {
+ perror(strerror(errno));
+ }
close(response[0]);
close(response[1]);
* Reading from file descriptor 0 reads from request pipe instead.
*/
close(0);
- dup(request[0]);
+ dupfp2 = dup(request[0]);
+ if(-1 == dupfp2) {
+ perror(strerror(errno));
+ }
close(request[0]);
close(request[1]);
* figure out path to dtgreet...
*/
- strcpy(msg, progName);
+ snprintf(msg, sizeof(msg), "%s", progName);
if ((p = (char *) strrchr(msg, '/')) == NULL)
strcpy(msg,"./");
else
- *(++p) = NULL;
+ *(++p) = '\0';
strcat(msg,"dtgreet");
* the master struct. When the user logs out, the
* resource-specified language (if any) will reactivate.
*/
- Debug("Greeter returned language '%s'\n", d->language);
+ if (d->language)
+ Debug("Greeter returned language '%s'\n", d->language);
+ else
+ Debug("Greeter returned language (NULL)\n");
+
if (strcmp(d->language, "default") == 0) {
int len = strlen(defaultLanguage) + 1;
TellGreeter(
RequestHeader *phdr)
{
- write(request[1], phdr, phdr->length);
+ if(-1 == write(request[1], phdr, phdr->length)) {
+ perror(strerror(errno));
+ }
}
static int