]> andersk Git - openssh.git/blobdiff - openbsd-compat/bsd-misc.c
- (djm) Enable new setproctitle emulation for Linux, AIX and HP/UX. More
[openssh.git] / openbsd-compat / bsd-misc.c
index d87d56218c8a856c39e185f3ca62b0295b45a604..b52a6f52ee32bf650545005a9a8e5acdd81e2dae 100644 (file)
  */
 
 #include "includes.h"
+#include "xmalloc.h"
 
 RCSID("$Id$");
 
+/*
+ * NB. duplicate __progname in case it is an alias for argv[0]
+ * Otherwise it may get clobbered by setproctitle()
+ */
 char *get_progname(char *argv0)
 {
 #ifdef HAVE___PROGNAME
        extern char *__progname;
 
-       return __progname;
+       return xstrdup(__progname);
 #else
        char *p;
 
@@ -42,7 +47,8 @@ char *get_progname(char *argv0)
                p = argv0;
        else
                p++;
-       return p;
+
+       return xstrdup(p);
 #endif
 }
 
@@ -93,9 +99,39 @@ int utimes(char *filename, struct timeval *tvp)
 {
        struct utimbuf ub;
 
-       ub.actime = tvp->tv_sec;
-       ub.modtime = tvp->tv_usec;
+       ub.actime = tvp[0].tv_sec;
+       ub.modtime = tvp[1].tv_sec;
        
        return(utime(filename, &ub));
 }
 #endif 
+
+#ifndef HAVE_TRUNCATE
+int truncate (const char *path, off_t length)
+{
+       int fd, ret, saverrno;
+
+       fd = open(path, O_WRONLY);
+       if (fd < 0)
+               return -1;
+
+       ret = ftruncate(fd, length);
+       saverrno = errno;
+       (void) close (fd);
+       if (ret == -1)
+               errno = saverrno;
+       return(ret);
+}
+#endif /* HAVE_TRUNCATE */
+
+#if !defined(HAVE_SETGROUPS) && defined(SETGROUPS_NOOP)
+/*
+ * Cygwin setgroups should be a noop.
+ */
+int
+setgroups(size_t size, const gid_t *list)
+{
+       return 0;
+}
+#endif 
+
This page took 0.035871 seconds and 4 git commands to generate.