mirror of OpenBSD xenocara tree github.com/openbsd/xenocara
openbsd
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

xenocara xlock uses imsg for privsep.

What changes:
- imsg_init becomes imsgbuf_init but imsgbuf_init can now fail
- Adding imsgbuf functions to hide the msgbuf functions:
msgbuf_clear -> imsgbuf_clear
msgbuf_write -> imsgbuf_write
- Also rename imsg_read to imsgbuf_read.
- Both imsgbuf_read and imsgbuf_write have simplified error handling.
imsgbuf_write now returns 0 on success so that old wrong connection
closed check must be removed
- Remove now official ibuf_get_string()

OK tb@ matthieu@

+12 -28
+12 -28
app/xlockmore/xlock/privsep.c
··· 1 - /* $OpenBSD: privsep.c,v 1.4 2024/01/22 10:13:34 claudio Exp $ */ 1 + /* $OpenBSD: privsep.c,v 1.5 2024/11/21 13:45:40 claudio Exp $ */ 2 2 /* 3 3 * Copyright 2001 Niels Provos <provos@citi.umich.edu> 4 4 * All rights reserved. ··· 83 83 static int 84 84 send_cmd(struct imsgbuf *ibuf, char *user, char *pass, char *style) 85 85 { 86 - size_t n, datalen = 0; 86 + size_t datalen = 0; 87 87 struct ibuf *wbuf; 88 88 struct priv_cmd_hdr hdr; 89 89 ··· 120 120 } 121 121 imsg_close(ibuf, wbuf); 122 122 123 - if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN) { 124 - warn("imsg_write"); 123 + if (imsgbuf_write(ibuf) == -1) { 124 + warn("imsgbuf_write"); 125 125 return -1; 126 126 } 127 - if (n == 0) 128 - return -1; 129 127 return 0; 130 128 } 131 129 132 - static char * 133 - ibuf_get_string(struct ibuf *buf, size_t len) 134 - { 135 - char *str; 136 - 137 - if (ibuf_size(buf) < len) { 138 - errno = EBADMSG; 139 - return (NULL); 140 - } 141 - str = strndup(ibuf_data(buf), len); 142 - if (str == NULL) 143 - return (NULL); 144 - buf->rpos += len; 145 - return (str); 146 - } 147 - 148 130 static int 149 131 receive_cmd(struct imsgbuf *ibuf, char **name, char **pass, char **style) 150 132 { ··· 154 136 ssize_t n, nread; 155 137 156 138 do { 157 - if ((nread = imsg_read(ibuf)) == -1 && errno != EAGAIN) { 158 - warn("imsg_read"); 139 + if ((nread = imsgbuf_read(ibuf)) == -1) { 140 + warn("imsgbuf_read"); 159 141 return -1; 160 142 } 161 143 if (nread == 0) { ··· 196 178 { 197 179 imsg_compose(ibuf, XLOCK_CHECKPW_RESULT, 0, 0, -1, 198 180 &result, sizeof(int)); 199 - return msgbuf_write(&ibuf->w); 181 + return imsgbuf_write(ibuf); 200 182 } 201 183 202 184 static int ··· 207 189 struct imsg imsg; 208 190 209 191 do { 210 - if ((nread = imsg_read(ibuf)) == -1 && errno != EAGAIN) 192 + if ((nread = imsgbuf_read(ibuf)) == -1) 211 193 return -1; 212 194 if (nread == 0) 213 195 return -1; ··· 244 226 return -1; 245 227 } 246 228 close(socks[0]); 247 - imsg_init(&parent_ibuf, socks[1]); 229 + if (imsgbuf_init(&parent_ibuf, socks[1]) == -1) 230 + return -1; 248 231 priv_inited = 1; 249 232 return 0; 250 233 } ··· 253 236 254 237 setproctitle("[priv]"); 255 238 256 - imsg_init(&child_ibuf, socks[0]); 239 + if (imsgbuf_init(&child_ibuf, socks[0]) == -1) 240 + err(1, "imsgbuf_init"); 257 241 258 242 if (unveil(_PATH_LOGIN_CONF, "r") == -1) 259 243 err(1, "unveil %s", _PATH_LOGIN_CONF);