* express or implied warranty.
*/
+#include "config.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
static char MORE[] = "more";
-extern char *_ss_pager_name;
extern char *getenv PROTOTYPE((const char *));
char *ss_safe_getenv(const char *arg)
if ((getuid() != geteuid()) || (getgid() != getegid()))
return NULL;
#if HAVE_PRCTL
- if (prctl(PR_GET_DUMPABLE) == 0)
+ if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) == 0)
return NULL;
#else
#if (defined(linux) && defined(SYS_prctl))
- if (syscall(SYS_prctl, PR_GET_DUMPABLE) == 0)
+ if (syscall(SYS_prctl, PR_GET_DUMPABLE, 0, 0, 0, 0) == 0)
return NULL;
#endif
#endif
-#ifdef HAVE___SECURE_GETENV
- return __secure_getenv("BLKID_FILE");
+#if defined(HAVE_SECURE_GETENV)
+ return secure_getenv(arg);
+#elif defined(HAVE___SECURE_GETENV)
+ return __secure_getenv(arg);
#else
- return getenv("BLKID_FILE");
+ return getenv(arg);
#endif
}
*/
#ifndef NO_FORK
-int ss_pager_create(void)
+int ss_pager_create(void)
{
int filedes[2];
-
+
if (pipe(filedes) != 0)
return(-1);
}
#endif
-void ss_page_stdin()
+static int write_all(int fd, char *buf, size_t count)
+{
+ ssize_t ret;
+ int c = 0;
+
+ while (count > 0) {
+ ret = write(fd, buf, count);
+ if (ret < 0) {
+ if ((errno == EAGAIN) || (errno == EINTR))
+ continue;
+ return -1;
+ }
+ count -= ret;
+ buf += ret;
+ c += ret;
+ }
+ return c;
+}
+
+void ss_page_stdin(void)
{
int i;
sigset_t mask;
-
+
for (i = 3; i < 32; i++)
(void) close(i);
(void) signal(SIGINT, SIG_DFL);
char buf[80];
register int n;
while ((n = read(0, buf, 80)) > 0)
- write(1, buf, n);
+ write_all(1, buf, n);
}
exit(errno);
}