Index: trunk/src/trustfile.c
===================================================================
--- trunk/src/trustfile.c	(revision 582)
+++ trunk/src/trustfile.c	(revision 1)
@@ -86,7 +86,4 @@
 #else
 #define UID_CAST long
-#define HAVE_GETPWENT
-#define SH_MUTEX_LOCK(a)   ((void)0)
-#define SH_MUTEX_UNLOCK(a) ((void)0)
 #endif
 
@@ -99,28 +96,22 @@
 #include <string.h>
 #include <unistd.h>
-#include <errno.h>
-
-
-#if !defined(TRUST_MAIN)
-
+
+
+#ifndef TRUST_MAIN
 #include "slib.h"
 #define SH_NEED_PWD_GRP 1
 #include "sh_static.h"
-#include "sh_pthread.h"
 
 #else
 
 #define sh_getgrgid   getgrgid
-#define sh_getgrgid_r getgrgid_r
+#define sh_getpwent   getpwent
 #define sh_getpwnam   getpwnam
-#define sh_getpwnam_r getpwnam_r
 #define sh_getpwuid   getpwuid
-#define sh_getpwuid_r getpwuid_r
-#define sh_getpwent   getpwent
 #define sh_endpwent   endpwent
 
 #define TRUST_DEBUG
-#define S_FALSE 0
-#define S_TRUE  1
+#define SL_FALSE 0
+#define SL_TRUE  1
 #define SL_ENTER(string)
 #define SL_IRETURN(a, b)  return a
@@ -136,5 +127,4 @@
 #define SL_EINTERNAL -1028     /* Internal error.                      */
 #define SL_EBADFILE  -1030     /* File access error. Check errno.      */
-#define SL_EMEM      -1032     /* Out of memory.                       */
 #define SL_EBADNAME  -1040     /* Invalid name.                        */
 #define SL_ESTAT     -1041     /* stat of file failed. Check errno.    */
@@ -211,5 +201,5 @@
 #define SL_ALWAYS_TRUSTED  0
 #endif
-uid_t test_rootonly[] = { SL_ALWAYS_TRUSTED };
+static uid_t test_rootonly[] = { SL_ALWAYS_TRUSTED };
 
 #define tf_uid_neg ((uid_t)-1)
@@ -222,6 +212,6 @@
 
 uid_t tf_euid = tf_uid_neg;
-unsigned int EUIDSLOT = sizeof(test_rootonly)/sizeof(uid_t);
-unsigned int ORIG_EUIDSLOT = sizeof(test_rootonly)/sizeof(uid_t);
+int EUIDSLOT = sizeof(test_rootonly)/sizeof(uid_t);
+int ORIG_EUIDSLOT = sizeof(test_rootonly)/sizeof(uid_t);
 
 char  tf_path[MAXFILENAME];		/* error path for trust function */
@@ -324,5 +314,5 @@
 
 /* not static to circumvent stupid gcc 4 bug */ 
-int getfname(const char *fname, char *rbuf, int rsz)
+int getfname(char *fname, char *rbuf, int rsz)
 {
 #ifndef TRUST_MAIN
@@ -367,8 +357,6 @@
 	SL_IRETURN(status, _("getfname"));
 #else
-      strncat(rbuf, "/",   rsz-strlen(rbuf)-1);
-      rbuf[rsz-1] = '\0';
-      strncat(rbuf, fname, rsz-strlen(rbuf)-1);
-      rbuf[rsz-1] = '\0';
+      strncat(rbuf, "/",   rsz-strlen(rbuf));
+      strncat(rbuf, fname, rsz-strlen(rbuf));
 #endif
     }
@@ -381,5 +369,5 @@
   SL_ENTER(_("isin"));
   if (list == NULL)
-    SL_IRETURN(S_FALSE, _("isin"));
+    SL_IRETURN(SL_FALSE, _("isin"));
 
   while(*list != tf_uid_neg && *list != n)
@@ -400,5 +388,5 @@
 	       (UID_CAST) n);
 #endif 
-      SL_IRETURN(S_FALSE, _("isin"));
+      SL_IRETURN(SL_FALSE, _("isin"));
     }
 
@@ -408,5 +396,5 @@
 	   (UID_CAST)n, (UID_CAST)*list);
 #endif 
-  SL_IRETURN(S_TRUE, _("isin"));
+  SL_IRETURN(SL_TRUE, _("isin"));
 }
 
@@ -415,65 +403,36 @@
  */
 /* not static to circumvent stupid gcc 4 bug */ 
-int isingrp(gid_t grp, uid_t *ulist, int * errval)
+int isingrp(gid_t grp, uid_t *ulist)
 {
-  struct passwd *w;	        /* info about group member */
+  register struct passwd *w;	/* info about group member */
   register uid_t *u;		/* points to current ulist member */
   register char **p;		/* points to current group member */
-  struct group *g;	        /* pointer to group information */
-
-  int status;
+  register struct group *g;	/* pointer to group information */
   
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-  struct group    gr;
-  char          * buffer = NULL;
-  struct passwd   pwd;
-  char          * pbuffer = NULL;
-#endif
-
   SL_ENTER(_("isingrp"));
 
-  *errval = 0;
-
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-  buffer = calloc(1,SH_GRBUF_SIZE);
-  status = sh_getgrgid_r(grp, &gr, buffer, SH_GRBUF_SIZE, &g);
+  if ((g = sh_getgrgid(grp)) == NULL)
+    {
+      SL_IRETURN(SL_FALSE, _("isingrp") );
+    }
+  /*
+  if(g->gr_mem == NULL || g->gr_mem[0] == NULL )
+    SL_IRETURN(SL_FALSE, _("isingrp") );
+  */
+
+  /* this will return at the first match
+   */
+  for(p = g->gr_mem; *p != NULL; p++)
+    {
+      for(u = ulist; *u != tf_uid_neg; u++)
+	{
+	  /* map user name to UID and compare */
+#ifdef TRUST_MAIN
+	  if ((w = getpwnam(*p)) != NULL && *u == (uid_t)(w->pw_uid) )
+	    SL_IRETURN(SL_TRUE, _("isingrp"));
 #else
-  errno = 0;
-  g = sh_getgrgid(grp);
-  status = errno;
-#endif
-
-  if (g == NULL)
-    {
-      if (status == ERANGE)
-	*errval = status;
-
-      goto end_false;
-    }
-
-  /* this will return at the first match
-   */
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-  pbuffer = calloc(1,SH_PWBUF_SIZE);
-#endif
-
-  for(p = g->gr_mem; *p != NULL; p++)
-    {
-      for(u = ulist; *u != tf_uid_neg; u++)
-	{
-	  /* map user name to UID and compare */
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
-	  sh_getpwnam_r(*p, &pwd, pbuffer, SH_PWBUF_SIZE, &w);
-#else
-	  w = sh_getpwnam(*p);
-#endif
-
-#ifdef TRUST_MAIN
-	  if (w != NULL && *u == (uid_t)(w->pw_uid) )
-	    goto end_true;
-#else
-	  if (w != NULL && *u == (uid_t)(w->pw_uid) )
-	    {
-	      goto end_true;
+	  if ((w = sh_getpwnam(*p)) != NULL && *u == (uid_t)(w->pw_uid) )
+	    {
+	      SL_IRETURN(SL_TRUE, _("isingrp"));
 	    }
 #endif
@@ -485,33 +444,16 @@
   for(u = ulist; *u != tf_uid_neg; u++)
     {
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R)
-      sh_getpwuid_r(*u, &pwd, pbuffer, SH_PWBUF_SIZE, &w);
+#ifdef TRUST_MAIN
+      if ((w = getpwuid(*u)) != NULL && grp == (gid_t)(w->pw_gid) )
+	SL_IRETURN(SL_TRUE, _("isingrp"));
 #else
-      w = sh_getpwuid(*u);
-#endif
-#ifdef TRUST_MAIN
-      if (w != NULL && grp == (gid_t)(w->pw_gid) )
-	goto end_true;
-#else
-      if (w != NULL && grp == (gid_t)(w->pw_gid) )
-	{
-	  goto end_true;
-	}
-#endif
-    }
-
- end_false:
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-  if (buffer)  free(buffer);
-  if (pbuffer) free(pbuffer);
-#endif
-  SL_IRETURN(S_FALSE, _("isingrp"));
-
- end_true:
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-  if (buffer)  free(buffer);
-  if (pbuffer) free(pbuffer);
-#endif
-  SL_IRETURN(S_TRUE, _("isingrp"));
+      if ((w = sh_getpwuid(*u)) != NULL && grp == (gid_t)(w->pw_gid) )
+	{
+	  SL_IRETURN(SL_TRUE, _("isingrp"));
+	}
+#endif
+    }
+
+  SL_IRETURN(SL_FALSE, _("isingrp"));
 }
 
@@ -520,26 +462,13 @@
  */
 /* not static to circumvent stupid gcc 4 bug */ 
-int onlytrustedingrp(gid_t grp, uid_t *ulist, int * errval)
+int onlytrustedingrp(gid_t grp, uid_t *ulist)
 {
-  struct passwd *w;	        /* info about group member */
+  register struct passwd *w;	/* info about group member */
   register uid_t *u;		/* points to current ulist member */
   register char **p;		/* points to current group member */
-  struct group *g;	        /* pointer to group information */
+  register struct group *g;	/* pointer to group information */
   register int flag = -1;       /* group member found */
 
-  int status;
-
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-  struct group    gr;
-  char          * buffer  = NULL;
-  struct passwd   pw;
-  char          * pbuffer = NULL;
-#endif
-
-  int retval = S_FALSE;
-
   SL_ENTER(_("onlytrustedingrp"));
-
-  *errval = 0;
 
 #ifdef TRUST_DEBUG
@@ -548,18 +477,6 @@
 #endif
 
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-  buffer = calloc(1,SH_GRBUF_SIZE);
-  status = sh_getgrgid_r(grp, &gr, buffer, SH_GRBUF_SIZE, &g);
-#else
-  errno = 0;
-  g = sh_getgrgid(grp);
-  status = errno;
-#endif
-
-  if (g == NULL)
-    {
-      if (status == ERANGE)
-	*errval = status;
-
+  if ((g = sh_getgrgid(grp)) == NULL)
+    {
 #ifdef TRUST_DEBUG
       fprintf(stderr, 
@@ -567,6 +484,5 @@
 	      (UID_CAST)grp); 
 #endif
-      retval = S_FALSE;
-      goto end_retval;
+      SL_IRETURN(SL_FALSE, _("onlytrustedingrp") );
     }
 
@@ -574,13 +490,9 @@
    
   if(g->gr_mem == NULL || g->gr_mem[0] == NULL )
-    SL_IRETURN(S_TRUE, _("onlytrustedingrp") );
+    SL_IRETURN(SL_TRUE, _("onlytrustedingrp") );
   */
 
   /* check for untrusted members of the group
    */
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
-  pbuffer = calloc(1,SH_PWBUF_SIZE);
-#endif
-
   for(p = g->gr_mem; *p != NULL; p++)
     {
@@ -591,10 +503,9 @@
       /* map user name to UID and compare 
        */
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
-      sh_getpwnam_r(*p, &pw, pbuffer, SH_PWBUF_SIZE, &w);
-#else
       w = sh_getpwnam(*p);
-#endif
-
+#ifndef TRUST_MAIN
+      if (!w)
+	w = sh_getpwnam(*p);
+#endif
       if (w == NULL)    /* not a valid user, ignore    */
 	{
@@ -640,15 +551,7 @@
 #endif 
 	  tf_baduid = w->pw_uid;
-	  retval = S_FALSE;
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-	  if (pbuffer) free(pbuffer);
-#endif
-	  goto end_retval;
-	}
-    }
-
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-  if (pbuffer) free(pbuffer);
-#endif
+	  SL_IRETURN(SL_FALSE, _("onlytrustedingrp"));
+	}
+    }
 
 #ifndef TEST_ONLY	
@@ -656,6 +559,4 @@
   /* now check ALL users for their GID !!!
    */
-  SH_MUTEX_LOCK(mutex_pwent);
-
   while (NULL != (w = sh_getpwent())) 
     {
@@ -676,5 +577,5 @@
 		  fprintf (stderr, 
 			   "trustfile: uid=%ld, trusted_uid=%ld, match found --> OK\n", 
-			   (UID_CAST)(w->pw_uid), (UID_CAST)(*u));
+			   (UID_CAST)(w->pw_uid), *u);
 #endif 
 		  flag = 0;
@@ -698,59 +599,39 @@
 #endif
 	      tf_baduid = w->pw_uid;
-	      retval = S_FALSE;
-	      goto out;
-	      /* SL_IRETURN(S_FALSE, _("onlytrustedingrp")); */
-	    }
-	}
-    }
-  retval = S_TRUE;
-
- out:
+	      SL_IRETURN(SL_FALSE, _("onlytrustedingrp"));
+	    }
+	}
+    }
 
 #ifdef HAVE_ENDPWENT
   sh_endpwent();
 #endif
-
-  SH_MUTEX_UNLOCK(mutex_pwent);
-
   /* TEST_ONLY */
 #endif
+
   /* #ifdef HAVE_GETPWENT */
 #endif
 
 #ifdef TRUST_DEBUG
-  if (retval == S_TRUE)
-    fprintf(stderr,
-	    "trustfile: group %ld:  all members are trusted users --> OK\n", 
-	    (UID_CAST)grp);
+  fprintf(stderr,
+	  "trustfile: group %ld:  all members are trusted users --> OK\n", 
+	  (UID_CAST)grp);
 #endif
   /* all found
    */
- end_retval:
-#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-  if (buffer)  free(buffer);
-#endif
-  SL_IRETURN(retval, _("onlytrustedingrp"));
+  SL_IRETURN(SL_TRUE, _("onlytrustedingrp"));
 }
 
-int sl_trustfile(const char *fname, uid_t *okusers, uid_t *badusers)
+int sl_trustfile(char *fname, uid_t *okusers, uid_t *badusers)
 {
-  char * fexp = NULL;	        /* file name fully expanded        */
-  register char *p;             /* used to hold name to be checked */
+  char fexp[MAXFILENAME];	/* file name fully expanded        */
+  register char *p = fexp;      /* used to hold name to be checked */
   struct stat stbuf;	        /* used to check file permissions  */
   char c;			/* used to hold temp char          */
   
-  int errgrp = 0;
-
   SL_ENTER(_("sl_trustfile"));
   if (fname == NULL)
     SL_IRETURN(SL_EBADFILE, _("sl_trustfile"));
 
-  fexp = calloc(1, MAXFILENAME );
-  if (!fexp)
-    SL_IRETURN(SL_EMEM, _("sl_trustfile"));
-
-  p = fexp;
-
   /*
    * next expand to the full file name
@@ -760,14 +641,8 @@
   sl_errno = getfname(fname, fexp, MAXFILENAME);
   if (sl_errno != 0)
-    {
-      free(fexp);
-      return sl_errno;
-    }
+    return sl_errno;
 #else
   if (SL_ISERROR(getfname(fname, fexp, MAXFILENAME)))
-    {
-      free(fexp);
       SL_IRETURN(sl_errno, _("sl_trustfile"));
-    }
 #endif
 
@@ -812,13 +687,11 @@
       if (retry_lstat(FIL__, __LINE__, fexp, &stbuf) < 0)
 	{
-	  (void) strncpy(tf_path, fexp, sizeof(tf_path));
-	  tf_path[sizeof(tf_path)-1] = '\0';
+	  (void) strcpy(tf_path, fexp);                  /* known to fit  */
 #ifdef TRUST_MAIN
 	  fprintf(stderr, "---------------------------------------------\n");
-	  fprintf(stderr, "trustfile: ESTAT: stat(%s) failed,\n", fexp);
-	  fprintf(stderr, "maybe the file does not exist\n");
+	      fprintf(stderr, "trustfile: ESTAT: stat(%s) failed, maybe the file does not exist\n",
+		      fexp);
 	  fprintf(stderr, "---------------------------------------------\n");
 #endif
-	  free(fexp);
 	  SL_IRETURN(SL_ESTAT, _("sl_trustfile"));
 	}
@@ -847,12 +720,9 @@
 	   * got it?
 	   */
-	  char * csym;	                /* contents of symlink file  */
-	  char * full;	                /* "full" name of symlink    */
-	  char *b;                      /* used to copy stuff around */
-	  const char *t;	        /* used to copy stuff around */
-	  int lsym;	                /* num chars in symlink ref  */
-	  int i;		        /* trustworthy or not?       */
-	  const char * t_const;
-	  char *end;
+	  char csym[MAXFILENAME];	/* contents of symlink file  */
+	  char full[MAXFILENAME];	/* "full" name of symlink    */
+	  register char *b, *t;	        /* used to copy stuff around */
+	  register int lsym;	        /* num chars in symlink ref  */
+	  register int i;		/* trustworthy or not?       */
 
 	  /*
@@ -864,11 +734,4 @@
 	   * R.W. Tue May 29 22:05:16 CEST 2001
 	   */
-	  csym = calloc(1, MAXFILENAME );
-	  if (!csym)
-	    {
-	      free(fexp);
-	      SL_IRETURN(SL_EMEM, _("sl_trustfile"));
-	    }
-
 	  lsym = readlink(fexp, csym, MAXFILENAME-1);
 	  if (lsym >= 0) 
@@ -882,15 +745,5 @@
 	      fprintf(stderr, "---------------------------------------------\n");
 #endif
-	      free(csym);
-	      free(fexp);
 	      SL_IRETURN(SL_EBADNAME, _("sl_trustfile"));
-	    }
-
-	  full = calloc(1, MAXFILENAME );
-	  if (!full)
-	    {
-	      free(csym);
-	      free(fexp);
-	      SL_IRETURN(SL_EMEM, _("sl_trustfile"));
 	    }
 
@@ -900,8 +753,4 @@
 	  if (csym[0] != '/')
 	    {
-	      /* pointer to one above last element
-	       */
-	      end = &full[MAXFILENAME-1]; ++end;
-
 	      /* initialize pointers 
 	       */
@@ -911,11 +760,11 @@
 	       */
 	      t = fexp;
-	      while(*t && b < end)
+	      while(*t && b < &full[MAXFILENAME])
 		*b++ = *t++;
 
 	      /* smack on the /../ 
 	       */
-	      t_const = "/../"; t = (const char *)t_const;
-	      while(*t && b < end)
+	      t = "/../";
+	      while(*t && b < &full[MAXFILENAME])
 		*b++ = *t++;
 
@@ -923,15 +772,14 @@
 	       */
 	      t = csym;
-	      while(*t && b < end)
+	      while(*t && b < &full[MAXFILENAME])
 		*b++ = *t++;
 
 	      /* see if we're too big 
 	       */
-	      if (*t || b == end)
+	      if (*t || b == &full[MAXFILENAME])
 		{
 		  /* yes -- error 
 		   */
-		  (void) strncpy(tf_path, fexp, sizeof(tf_path));
-		  tf_path[sizeof(tf_path)-1] = '\0';
+		  (void) strcpy(tf_path, fexp);          /* known to fit  */
 #ifdef TRUST_MAIN
 		  fprintf(stderr, "---------------------------------------------\n");
@@ -941,7 +789,4 @@
 		  fprintf(stderr, "---------------------------------------------\n");
 #endif
-		  free(full);
-		  free(csym);
-		  free(fexp);
 		  SL_IRETURN(SL_ETRUNC, _("sl_trustfile"));
 		}
@@ -959,10 +804,5 @@
 	   */
 	  if ((i = sl_trustfile(full, okusers, badusers)) != SL_ENONE)
-	    {
-	      free(full);
-	      free(csym);
-	      free(fexp);
-	      SL_IRETURN(i, _("sl_trustfile"));
-	    }
+	    SL_IRETURN(i, _("sl_trustfile"));
 
 	  /*
@@ -983,6 +823,4 @@
 		p++;
 	    }
-	  free(full);
-	  free(csym);
 	  continue;
 	}
@@ -998,6 +836,6 @@
        * file regardless of permissions, so bomb
        */
-      if (((okusers != NULL && S_FALSE == isin((uid_t)stbuf.st_uid,okusers))||
-	   (badusers != NULL && S_TRUE == isin((uid_t)stbuf.st_uid,badusers))))
+      if (((okusers != NULL && SL_FALSE == isin((uid_t)stbuf.st_uid,okusers))||
+	   (badusers != NULL && SL_TRUE == isin((uid_t)stbuf.st_uid,badusers))))
 	{
 #ifdef TRUST_DEBUG
@@ -1012,9 +850,6 @@
 	  fprintf(stderr, "---------------------------------------------\n");
 #endif 
-	  (void) strncpy(tf_path, fexp, sizeof(tf_path));
-	  tf_path[sizeof(tf_path)-1] = '\0';
-
+	  (void) strcpy(tf_path, fexp);                  /* known to fit  */
 	  tf_baduid = (uid_t) stbuf.st_uid;
-	  free(fexp);
 	  SL_IRETURN(SL_EBADUID, _("sl_trustfile"));
 	}
@@ -1032,6 +867,6 @@
        */
       if (((stbuf.st_mode & S_IWGRP) == S_IWGRP) &&
-	  ((okusers != NULL && !onlytrustedingrp((gid_t)stbuf.st_gid,okusers,&errgrp))||
-	   (badusers != NULL && isingrp((gid_t)stbuf.st_gid, badusers,&errgrp)))
+	  ((okusers != NULL && !onlytrustedingrp((gid_t)stbuf.st_gid,okusers))||
+	   (badusers != NULL && isingrp((gid_t)stbuf.st_gid, badusers)))
 #ifdef STICKY
 	  && ((stbuf.st_mode&S_IFDIR) != S_IFDIR ||
@@ -1052,10 +887,7 @@
 	  fprintf(stderr, "---------------------------------------------\n");
 #endif 
-	  (void) strncpy(tf_path, fexp, sizeof(tf_path));
-	  tf_path[sizeof(tf_path)-1] = '\0';
-
+	  (void) strcpy(tf_path, fexp);                  /* known to fit  */
 	  tf_badgid = (gid_t) stbuf.st_gid;
-	  free(fexp);
-	  SL_IRETURN((errgrp == ERANGE) ? SL_ERANGE : SL_EBADGID, _("sl_trustfile"));
+	  SL_IRETURN(SL_EBADGID, _("sl_trustfile"));
 	}
       /*
@@ -1077,8 +909,5 @@
 	  fprintf(stderr, "---------------------------------------------\n");
 #endif 
-	  (void) strncpy(tf_path, fexp, sizeof(tf_path));
-	  tf_path[sizeof(tf_path)-1] = '\0';
-
-	  free(fexp);
+	  (void) strcpy(tf_path, fexp);                  /* known to fit  */
 	  SL_IRETURN(SL_EBADOTH, _("sl_trustfile"));
 	}
@@ -1103,19 +932,9 @@
    * yes, it can be trusted
    */
-  (void) strncpy(tf_path, fexp, sizeof(tf_path));
-  tf_path[sizeof(tf_path)-1] = '\0';
-
-  free(fexp);
+  (void) strcpy(tf_path, fexp);                      /* known to fit  */
   SL_IRETURN(SL_ENONE, _("sl_trustfile"));
 }
 
 #ifdef TRUST_MAIN
-
-#if defined(HOST_IS_CYGWIN) || defined(__cygwin__) || defined(__CYGWIN32__) || defined(__CYGWIN__)
-int main()
-{
-  return 0;
-}
-#else
 int main (int argc, char * argv[])
 {
@@ -1132,5 +951,5 @@
   tf_path[0] = '\0';
 #if defined(SH_WITH_SERVER)
-  pass = sh_getpwnam(SH_IDENT);  /* TESTONLY */
+  pass = getpwnam(SH_IDENT);
   if (pass != NULL)
     tf_euid = pass->pw_uid;
@@ -1155,6 +974,5 @@
 }
 #endif
-#endif
-
-
-
+
+
+
