summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Hieber <r.hieber@pengutronix.de>2017-07-24 16:40:10 +0200
committerRoland Hieber <r.hieber@pengutronix.de>2017-07-25 21:26:10 +0200
commite6b6377a99813e3f0f000cfa3d2e8118c3e08337 (patch)
treee783e143820163a620d7ab89bf428d38698ca5cf
parent8a103f5c91133e3443774cc4a2ba74570484ec0c (diff)
downloadurshd-e6b6377a99813e3f0f000cfa3d2e8118c3e08337.tar.gz
urshd-e6b6377a99813e3f0f000cfa3d2e8118c3e08337.tar.xz
urshd: fix indentation
This changes only whitespace, and adds a vim modeline to pin down the code style. Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
-rw-r--r--src/urshd.c165
1 files changed, 83 insertions, 82 deletions
diff --git a/src/urshd.c b/src/urshd.c
index a0af916..ddcf86f 100644
--- a/src/urshd.c
+++ b/src/urshd.c
@@ -121,7 +121,7 @@ static char homedir[64] = "HOME=";
static char shell[64] = "SHELL=";
static char path[100] = "PATH=";
static char *envinit[] = {homedir, shell, path, username, NULL};
-extern char **environ;
+extern char **environ;
static void error(const char *fmt, ...);
static void doit(struct sockaddr_in6 *fromp);
@@ -190,104 +190,104 @@ fatal(const char *fmt, ...)
static void
error(const char *fmt, ...)
{
- va_list ap;
- char buf[BUFSIZ], *bp = buf;
+ va_list ap;
+ char buf[BUFSIZ], *bp = buf;
- if (sent_null == 0) {
- *bp++ = 1;
- }
+ if (sent_null == 0) {
+ *bp++ = 1;
+ }
- va_start(ap, fmt);
- vsnprintf(bp, sizeof(buf) - 1, fmt, ap);
- va_end(ap);
+ va_start(ap, fmt);
+ vsnprintf(bp, sizeof(buf) - 1, fmt, ap);
+ va_end(ap);
- if (write(2, buf, strlen(buf)) != 0) {
- fatal("error: write: %m");
- }
+ if (write(2, buf, strlen(buf)) != 0) {
+ fatal("error: write: %m");
+ }
}
static void
getstr(char *buf, int cnt, const char *err)
{
- char c;
- do {
- if (read(0, &c, 1) != 1) exit(1);
- *buf++ = c;
- if (--cnt == 0) {
- error("%s too long\n", err);
- exit(1);
- }
- } while (c != 0);
+ char c;
+ do {
+ if (read(0, &c, 1) != 1) exit(1);
+ *buf++ = c;
+ if (--cnt == 0) {
+ error("%s too long\n", err);
+ exit(1);
+ }
+ } while (c != 0);
}
static int
getint(void)
{
- int port = 0;
- char c;
- do {
- if (read(0, &c, 1) != 1)
- exit(1);
- if (isascii(c) && isdigit(c))
- port = port*10 + c-'0';
- } while (c != 0);
- return port;
+ int port = 0;
+ char c;
+ do {
+ if (read(0, &c, 1) != 1)
+ exit(1);
+ if (isascii(c) && isdigit(c))
+ port = port*10 + c-'0';
+ } while (c != 0);
+ return port;
}
static void
stderr_parent(int sock, int pype, int pid)
{
- fd_set ready, readfrom;
- char buf[BUFSIZ], sig;
- int one = 1;
- int nfd, cc, guys=2;
-
- ioctl(pype, FIONBIO, (char *)&one);
- /* should set s nbio! */
-
- FD_ZERO(&readfrom);
- FD_SET(sock, &readfrom);
- FD_SET(pype, &readfrom);
-
- if (pype > sock)
- nfd = pype+1;
- else
- nfd = sock+1;
-
- while (guys > 0) {
- ready = readfrom;
- if (select(nfd, &ready, NULL, NULL, NULL) < 0) {
- if (errno != EINTR) {
- break;
- }
- continue;
- }
- if (FD_ISSET(sock, &ready)) {
- cc = read(sock, &sig, 1);
- if (cc <= 0) {
- FD_CLR(sock, &readfrom);
- guys--;
- } else
- killpg(pid, sig);
- }
- if (FD_ISSET(pype, &ready)) {
- cc = read(pype, buf, sizeof(buf));
- if (cc <= 0) {
- shutdown(sock, 2);
- FD_CLR(pype, &readfrom);
- guys--;
- } else {
- if (write(sock, buf, cc) != 0) {
- fatal("stderr_parent: %m");
+ fd_set ready, readfrom;
+ char buf[BUFSIZ], sig;
+ int one = 1;
+ int nfd, cc, guys=2;
+
+ ioctl(pype, FIONBIO, (char *)&one);
+ /* should set s nbio! */
+
+ FD_ZERO(&readfrom);
+ FD_SET(sock, &readfrom);
+ FD_SET(pype, &readfrom);
+
+ if (pype > sock)
+ nfd = pype+1;
+ else
+ nfd = sock+1;
+
+ while (guys > 0) {
+ ready = readfrom;
+ if (select(nfd, &ready, NULL, NULL, NULL) < 0) {
+ if (errno != EINTR) {
+ break;
+ }
+ continue;
+ }
+ if (FD_ISSET(sock, &ready)) {
+ cc = read(sock, &sig, 1);
+ if (cc <= 0) {
+ FD_CLR(sock, &readfrom);
+ guys--;
+ } else
+ killpg(pid, sig);
+ }
+ if (FD_ISSET(pype, &ready)) {
+ cc = read(pype, buf, sizeof(buf));
+ if (cc <= 0) {
+ shutdown(sock, 2);
+ FD_CLR(pype, &readfrom);
+ guys--;
+ } else {
+ if (write(sock, buf, cc) != 0) {
+ fatal("stderr_parent: %m");
+ }
+ }
}
- }
}
- }
- close(sock);
- close(pype);
+ close(sock);
+ close(pype);
- exit(0);
+ exit(0);
}
static void
@@ -322,7 +322,7 @@ doit(struct sockaddr_in6 *fromp)
}
fromp->sin6_port = htons(port);
if (connect(sock, (struct sockaddr *)fromp,
- sizeof(*fromp)) < 0) {
+ sizeof(*fromp)) < 0) {
syslog(LOG_INFO, "connect second port: %m");
exit(1);
}
@@ -386,13 +386,13 @@ doit(struct sockaddr_in6 *fromp)
theshell = pwd->pw_shell;
if (!theshell || !*theshell) {
- /* shouldn't we deny access? */
- theshell = _PATH_BSHELL;
+ /* shouldn't we deny access? */
+ theshell = _PATH_BSHELL;
}
#if BSD > 43
if (setlogin(pwd->pw_name) < 0) {
- syslog(LOG_ERR, "setlogin() failed: %m");
+ syslog(LOG_ERR, "setlogin() failed: %m");
}
#endif
if (setgid(pwd->pw_gid)) {
@@ -429,7 +429,7 @@ doit(struct sockaddr_in6 *fromp)
endpwent();
if (0) {
- syslog(LOG_INFO|LOG_AUTH, "%s as %s: cmd='%s'", remuser, locuser, cmdbuf);
+ syslog(LOG_INFO|LOG_AUTH, "%s as %s: cmd='%s'", remuser, locuser, cmdbuf);
}
/*
@@ -650,3 +650,4 @@ main(int argc, char *argv[])
mainloop();
return 0;
}
+/* vim: set ft=c ts=8 noet */