summaryrefslogtreecommitdiff
path: root/openbsd-compat/bsd-misc.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2018-04-03 08:20:28 +0100
committerColin Watson <cjwatson@debian.org>2018-04-03 08:20:28 +0100
commited6ae9c1a014a08ff5db3d768f01f2e427eeb476 (patch)
tree601025e307745d351946c01ab13f419ddb6dae29 /openbsd-compat/bsd-misc.c
parent62f54f20bf351468e0124f63cc2902ee40d9b0e9 (diff)
parenta0349a1cc4a18967ad1dbff5389bcdf9da098814 (diff)
Import openssh_7.7p1.orig.tar.gz
Diffstat (limited to 'openbsd-compat/bsd-misc.c')
-rw-r--r--openbsd-compat/bsd-misc.c81
1 files changed, 43 insertions, 38 deletions
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 29f6ad38c..3daf61071 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -104,16 +104,6 @@ const char *strerror(int e)
104} 104}
105#endif 105#endif
106 106
107#if !defined(HAVE_STRSIGNAL)
108char *strsignal(int sig)
109{
110 static char buf[16];
111
112 (void)snprintf(buf, sizeof(buf), "%d", sig);
113 return buf;
114}
115#endif
116
117#ifndef HAVE_UTIMES 107#ifndef HAVE_UTIMES
118int utimes(char *filename, struct timeval *tvp) 108int utimes(char *filename, struct timeval *tvp)
119{ 109{
@@ -221,33 +211,6 @@ tcsendbreak(int fd, int duration)
221} 211}
222#endif /* HAVE_TCSENDBREAK */ 212#endif /* HAVE_TCSENDBREAK */
223 213
224mysig_t
225mysignal(int sig, mysig_t act)
226{
227#ifdef HAVE_SIGACTION
228 struct sigaction sa, osa;
229
230 if (sigaction(sig, NULL, &osa) == -1)
231 return (mysig_t) -1;
232 if (osa.sa_handler != act) {
233 memset(&sa, 0, sizeof(sa));
234 sigemptyset(&sa.sa_mask);
235 sa.sa_flags = 0;
236#ifdef SA_INTERRUPT
237 if (sig == SIGALRM)
238 sa.sa_flags |= SA_INTERRUPT;
239#endif
240 sa.sa_handler = act;
241 if (sigaction(sig, &sa, NULL) == -1)
242 return (mysig_t) -1;
243 }
244 return (osa.sa_handler);
245#else
246 #undef signal
247 return (signal(sig, act));
248#endif
249}
250
251#ifndef HAVE_STRDUP 214#ifndef HAVE_STRDUP
252char * 215char *
253strdup(const char *str) 216strdup(const char *str)
@@ -275,7 +238,7 @@ isblank(int c)
275pid_t 238pid_t
276getpgid(pid_t pid) 239getpgid(pid_t pid)
277{ 240{
278#if defined(HAVE_GETPGRP) && !defined(GETPGRP_VOID) 241#if defined(HAVE_GETPGRP) && !defined(GETPGRP_VOID) && GETPGRP_VOID == 0
279 return getpgrp(pid); 242 return getpgrp(pid);
280#elif defined(HAVE_GETPGRP) 243#elif defined(HAVE_GETPGRP)
281 if (pid == 0) 244 if (pid == 0)
@@ -319,3 +282,45 @@ llabs(long long j)
319 return (j < 0 ? -j : j); 282 return (j < 0 ? -j : j);
320} 283}
321#endif 284#endif
285
286#ifndef HAVE_BZERO
287void
288bzero(void *b, size_t n)
289{
290 (void)memset(b, 0, n);
291}
292#endif
293
294#ifndef HAVE_RAISE
295int
296raise(int sig)
297{
298 kill(getpid(), sig);
299}
300#endif
301
302#ifndef HAVE_GETSID
303pid_t
304getsid(pid_t pid)
305{
306 errno = ENOSYS;
307 return -1;
308}
309#endif
310
311#ifdef FFLUSH_NULL_BUG
312#undef fflush
313int _ssh_compat_fflush(FILE *f)
314{
315 int r1, r2, r3;
316
317 if (f == NULL) {
318 r2 = fflush(stdout);
319 r3 = fflush(stderr);
320 if (r1 == -1 || r2 == -1 || r3 == -1)
321 return -1;
322 return 0;
323 }
324 return fflush(f);
325}
326#endif