Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP5:GA
blog.29849
blog.dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File blog.dif of Package blog.29849
diff --git blogctl.c blogctl.c index 4ea30b5..fbe582d 100644 --- blogctl.c +++ blogctl.c @@ -35,11 +35,11 @@ static int getsocket(void) return fd; } -static int getcmd(int argc, char *argv[]) +static char getcmd(int argc, char *argv[]) { static const struct { const char* cmd; - const int req; + const char req; const int arg; const char* opt; } cmds[] = { @@ -53,7 +53,7 @@ static int getcmd(int argc, char *argv[]) { "reactivate", MAGIC_REACTIVATE, 0, NULL }, /* Reactivate logging */ {} }, *cmd = cmds; - int ret = -1; + char ret = (char)-1; if (argc <= 1) goto out; @@ -87,7 +87,13 @@ int main(int argc, char *argv[]) int fdsock = -1, ret, len; cmd[1] = '\0'; - while ((cmd[0] = getcmd(argc, argv)) != -1) { + answer[0] = '\x15'; + + fdsock = getsocket(); + if (fdsock < 0) + error("no blogd active"); + + while ((cmd[0] = getcmd(argc, argv)) != (char)-1) { switch (cmd[0]) { case MAGIC_CHROOT: root = optarg; @@ -100,9 +106,7 @@ int main(int argc, char *argv[]) ret = asprintf(&message, "%c\002%c%s%n", cmd[0], (int)(strlen(root) + 1), root, &len); if (ret < 0) error("can not allocate message"); - fdsock = getsocket(); - if (fdsock >= 0) - safeout(fdsock, message, len+1, SSIZE_MAX); + safeout(fdsock, message, len+1, SSIZE_MAX); free(message); break; case MAGIC_PING: @@ -112,24 +116,26 @@ int main(int argc, char *argv[]) case MAGIC_CLOSE: case MAGIC_DEACTIVATE: case MAGIC_REACTIVATE: - fdsock = getsocket(); - if (fdsock >= 0) - safeout(fdsock, cmd, strlen(cmd)+1, SSIZE_MAX); + safeout(fdsock, cmd, strlen(cmd)+1, SSIZE_MAX); break; - case '?': - default: - return 1; + case '?': + default: + goto fail; } - answer[0] = '\0'; - if (fdsock >= 0) { - if (can_read(fdsock, 1000)) - safein(fdsock, &answer[0], sizeof(answer)); - close(fdsock); + if (can_read(fdsock, 1000)) { + answer[0] = '\0'; + safein(fdsock, &answer[0], sizeof(answer)); } + + break; /* One command per call only */ } + argv += optind; argc -= optind; +fail: + if (fdsock >= 0) + close(fdsock); return answer[0] == '\x6' ? 0 : 1; } diff --git libconsole/console.c libconsole/console.c index 89ae1e5..361d452 100644 --- libconsole/console.c +++ libconsole/console.c @@ -49,6 +49,16 @@ # define _PATH_BLOG_FIFO "/dev/blog" #endif +#if defined(__s390__) +# define RED "" +# define BOLD ">> " +# define NORM "" +#else +# define RED "\e[31m" +# define BOLD "\e[1m" +# define NORM "\e[m" +#endif + int final = 0; static volatile char *_arg0; @@ -101,9 +111,23 @@ static void (*vc_reconnect)(int fd); void safeout (int fd, const void *ptr, size_t s, ssize_t max) { int saveerr = errno; + int issocket = 0; + struct stat st; + + if (fstat(fd, &st) < 0) + goto out; + if (S_ISSOCK(st.st_mode)) + issocket++; while (s > 0) { - ssize_t p = write (fd, ptr, (max < 1) ? 1 : ((s < (size_t)max) ? s : (size_t)max)); + ssize_t p; + if (issocket) { + int flags = MSG_NOSIGNAL; + if (s > max) + flags |= MSG_MORE; + p = send (fd, ptr, (max < 1) ? 1 : ((s < (size_t)max) ? s : (size_t)max), flags); + } else + p = write (fd, ptr, (max < 1) ? 1 : ((s < (size_t)max) ? s : (size_t)max)); if (p < 0) { if (errno == EPIPE) break; @@ -167,7 +191,7 @@ ssize_t safein (int fd, void *ptr, size_t s) if (safein_noexit || signaled) goto out; if (fd == 0 && errno == EIO) - warn("\e[31m\e[1msystem console stolen at line %d!\e[m", __LINE__); + warn(RED BOLD "system console stolen at line %d!" NORM, __LINE__); lerror("Can not read from fd %d", fd); } @@ -191,7 +215,7 @@ ssize_t safein (int fd, void *ptr, size_t s) if (safein_noexit || signaled) goto out; if (fd == 0 && errno == EIO) - warn("\e[31m\e[1msystem console stolen at line %d!\e[m", __LINE__); + warn(RED BOLD "system console stolen at line %d!" NORM, __LINE__); lerror("Can not read from fd %d", fd); } repeated = 0; @@ -1184,7 +1208,7 @@ static void ask_for_password(void) if (c->flags & CON_SERIAL) len = asprintf(&message, "\n\r%s: ", pwprompt); else - len = asprintf(&message, "\e[1m\r%s:\e[m ", pwprompt); + len = asprintf(&message, BOLD "\r%s: " NORM, pwprompt); if (len < 0) { warn("can not set password prompt"); _exit(1); diff --git libconsole/readpw.c libconsole/readpw.c index 34a9674..b2f2d66 100644 --- libconsole/readpw.c +++ libconsole/readpw.c @@ -28,12 +28,12 @@ ssize_t readpw(int fd, char *pass, int eightbit) { char *ptr = pass; struct chardata cp; - int c, ret; + int ret; cp.eol = *ptr = '\0'; while (cp.eol == '\0') { - char ascval; + char ascval, c; ret = read(fd, &c, 1); if (ret < 0) { @@ -58,7 +58,7 @@ ssize_t readpw(int fd, char *pass, int eightbit) if (eightbit) ascval = c; else if (c != (ascval = (c & 0177))) { - uint32_t bits, mask; + uint8_t bits, mask; for (bits = 1, mask = 1; mask & 0177; mask <<= 1) { if (mask & ascval) bits++;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor