|
I wrote:
> In this case, I think the best solution would be to
> use the $HOME and $LOGNAME (or $USER) environment variables rather than
> the password database.
And here's a patch that does this:
Index: conf.c
===================================================================
RCS file: /cvsroot/tn5250/tn5250/src/conf.c,v
retrieving revision 1.13
diff -u -r1.13 conf.c
--- conf.c 8 Mar 2005 16:51:55 -0000 1.13
+++ conf.c 10 Sep 2005 07:56:58 -0000
@@ -415,7 +415,7 @@
int
tn5250_config_load_default (Tn5250Config * This)
{
- struct passwd *pwent;
+ const char *home;
char *dir;
int ec;
@@ -425,21 +425,21 @@
return -1;
}
- pwent = getpwuid (getuid ());
- if (pwent == NULL)
+ home = getenv ("HOME");
+ if (home == NULL)
{
- perror ("getpwuid");
+ fputs("No value for HOME environment variable.\n", stderr);
return -1;
}
- dir = (char *) malloc (strlen (pwent->pw_dir) + 12);
+ dir = (char *) malloc (strlen (home) + 12);
if (dir == NULL)
{
perror ("malloc");
return -1;
}
- strcpy (dir, pwent->pw_dir);
+ strcpy (dir, home);
strcat (dir, "/.tn5250rc");
if ((ec = tn5250_config_load (This, dir)) == -1)
perror (dir);
@@ -648,12 +648,10 @@
}
#else
{
- struct passwd *pwent;
- pwent = getpwuid (getuid ());
- if (pwent != NULL)
+ const char *logname = getenv("LOGNAME");
+ if (logname != NULL)
{
- tn5250_config_replacedata ("$loginname$", pwent->pw_name, buf,
- maxlen);
+ tn5250_config_replacedata ("$loginname$", logname, buf, maxlen);
}
}
#endif
Index: macro.c
===================================================================
RCS file: /cvsroot/tn5250/tn5250/src/macro.c,v
retrieving revision 1.4
diff -u -r1.4 macro.c
--- macro.c 8 Mar 2005 16:51:59 -0000 1.4
+++ macro.c 10 Sep 2005 07:56:58 -0000
@@ -340,19 +340,19 @@
*/
char *macro_filename (Tn5250Display *Dsp)
{
- struct passwd *pwent;
+ const char *home;
char *dir, *fname;
const char *cnf ;
- pwent = getpwuid (getuid ());
- if (pwent == NULL)
+ home = getenv ("HOME");
+ if (home == NULL)
return (NULL) ;
- dir = (char *)malloc (strlen (pwent->pw_dir) + 16);
+ dir = (char *)malloc (strlen (home) + 16);
if (dir == NULL)
return (NULL) ;
- strcpy (dir, pwent->pw_dir);
+ strcpy (dir, home);
strcat (dir, "/.tn5250macros");
fname = dir ;
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.