Changeset 4a74b5b in code
- Timestamp:
- Apr 17, 2025, 11:33:16 PM (7 weeks ago)
- Branches:
- master
- Parents:
- 2be3612
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r2be3612 r4a74b5b 1 1 PREFIX?= /usr/local 2 2 BINDIR= ${PREFIX}/sbin 3 MANDIR= ${PREFIX}/man/man 3 MANDIR= ${PREFIX}/man/man8 4 4 5 5 PROG= icbd … … 7 7 MAN= icbd.8 8 8 9 .ifdef __OpenBSD__ 9 10 CFLAGS+= -W -Wall -Werror 10 11 CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations 11 12 CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare 13 .endif 12 14 13 15 DPADD= ${LIBEVENT} -
README
r2be3612 r4a74b5b 1 icbd: a simple ICB daemon written in C 2 ====================================== 3 4 http://www.icb.net/ 5 http://www.icb.net/_jrudd/icb/protocol.html 1 _____________________ 2 ( A simple ICB daemon ) 3 --------------------- 4 \ 5 \ 6 \ ,__--**@@@**--__, 7 \ ,@%* *%@m, 8 ,@* # +@*# @ *@, 9 ,@* @ # __ @ @, 10 ,*@m#, @, m*@ %_- ,@ ,#m@*, 11 ,@@*-% @ # # @ %-+m, 12 @ @ @#=====#================#=====#@ @ %, 13 @* ,*@m,## ##,m@*, @ 14 # :@ #====---__________________---====# @: @ 15 @* :@ @ @. @: @ 16 @ *m__m* #m, .# *m__* @ 17 @ @ .# % @ @ @ =- @* 18 *, % ,% @ @ @ @. *% #, .- ,@ 19 @ *@ @ @, @ *@ :@ @ ,@ *, @. @ 20 @ @@. % *# @ ,@* #+* % .@ @ 21 @ % @, @ m--#@+*+@#-- # --#@+*+@#--m @ ,@+ @ 22 .@ @ *@# | @ @ @ @ @ @ | +@ ,@ % *, 23 ,@ @, @ @*^ @ @*^ @ @ #%* @ %, 24 ,@ *% @ @ @ % @ @ @ % 25 @ ,*@ % *=_=* *=_=* % ,*+ @ 26 %* m* @ % % % @, @ 27 @ @* % ,@ @, @ @ @: 28 @ @ @ @ *_* @ @ @ @: 29 @: %, %, @**__, ,__**@ @ _% @ 30 @, *_ @, @ @. *--__, ,__--* .@ @ @ #, ,@* 31 *--__+# @, @ @, . ^^^^^ . ,@ * ,@ *+@@* 32 ^*+# *%__*%,m***m,%*__%* #@@+* 33 O O *= 34 *m_m* 35 # # 36 # @*# 37 # -# 38 #+*^ -
dns.c
r2be3612 r4a74b5b 28 28 #include <syslog.h> 29 29 30 #ifdef __NetBSD__ 31 #define NO_ASYNC 32 #endif 33 34 #ifdef NO_ASYNC 35 struct asr_result { 36 struct addrinfo* ar_addrinfo; 37 int ar_gai_errno; 38 }; 39 #else 30 40 #include <asr.h> 41 #endif 31 42 32 43 #include "icb.h" … … 86 97 { 87 98 struct icb_session *is = arg; 99 #ifdef NO_ASYNC 100 struct asr_result result; 101 #else 88 102 struct asr_query *as; 103 #endif 89 104 struct addrinfo hints; 90 105 … … 100 115 memset(&hints, 0, sizeof(hints)); 101 116 hints.ai_family = PF_UNSPEC; 117 #ifdef NO_ASYNC 118 getaddrinfo(is->hostname, NULL, &hints, &result.ar_addrinfo); 119 result.ar_gai_errno = errno; 120 dns_done_host(&result, is); 121 #else 102 122 as = getaddrinfo_async(is->hostname, NULL, &hints, NULL); 103 123 event_asr_run(as, dns_done_host, is); 124 #endif 104 125 } else { 105 126 icbd_log(is, LOG_DEBUG, "reverse dns resolution failed: %s", … … 130 151 dns_resolve(struct icb_session *is) 131 152 { 153 #ifdef NO_ASYNC 154 struct asr_result result; 155 #else 132 156 struct asr_query *as; 157 #endif 133 158 134 159 if (!dodns) … … 140 165 icbd_log(is, LOG_DEBUG, "resolving: %s", is->host); 141 166 167 #ifdef NO_ASYNC 168 getnameinfo((struct sockaddr *)&is->ss, 169 ((struct sockaddr *)&is->ss)->sa_len, is->hostname, 170 sizeof is->hostname, NULL, 0, NI_NOFQDN); 171 result.ar_gai_errno = errno; 172 dns_done_reverse(&result, is); 173 #else 142 174 as = getnameinfo_async((struct sockaddr *)&is->ss, 143 175 ((struct sockaddr *)&is->ss)->sa_len, is->hostname, 144 176 sizeof is->hostname, NULL, 0, NI_NOFQDN, NULL); 145 177 event_asr_run(as, dns_done_reverse, is); 178 #endif 146 179 } 147 180 -
icb.c
r2be3612 r4a74b5b 579 579 LIST_FOREACH(s, &ig->sess, entry) { 580 580 (void)snprintf(buf, sizeof buf, 581 #ifdef __NetBSD__ 582 "%c%c%s%c%ld%c0%c%ld%c%s%c%s%c%s", 583 #else 581 584 "%c%c%s%c%lld%c0%c%lld%c%s%c%s%c%s", 585 #endif 582 586 icb_ismod(ig, s) ? 'm' : ' ', ICB_M_SEP, 583 587 s->nick, ICB_M_SEP, now - s->last, -
icbd.c
r2be3612 r4a74b5b 2 2 * Copyright (c) 2009 Mike Belopuhov 3 3 * Copyright (c) 2007 Oleg Safiullin 4 * Copyright (c) 2024 Nishi 5 * Copyright (C) 2025 Izuru Yakumo 4 6 * 5 7 * Permission to use, copy, modify, and distribute this software for any … … 175 177 hints.ai_socktype = SOCK_STREAM; 176 178 hints.ai_flags = AI_PASSIVE; 179 #ifdef __OpenBSD__ 180 /* Apparently OpenBSD is the only one that has icb on /etc/services */ 181 /* Sure, it could be easily added to any other system, but I'm personally against it */ 182 /* ~Izuru Yakumo */ 177 183 if ((error = getaddrinfo(addr, port ? port : "icb", &hints, 178 184 &res0)) != 0) { … … 180 186 return (EX_UNAVAILABLE); 181 187 } 182 188 #else 189 if ((error = getaddrinfo(addr, port ? port : "7326", &hints, &res0)) != 0) { 190 syslog(LOG_ERR, "%s", gai_strerror(error)); 191 return (EX_UNAVAILABLE); 192 } 193 #endif 183 194 for (res = res0; res != NULL; res = res->ai_next) { 184 195 if ((s = socket(res->ai_family, res->ai_socktype, … … 476 487 exit(EX_NOPERM); 477 488 } 478 489 #ifdef __OpenBSD__ 479 490 if (sb.st_uid != 0 || (sb.st_mode & (S_IWGRP|S_IWOTH)) != 0) { 480 491 syslog(LOG_ERR, "bad directory permissions"); 481 492 exit(EX_NOPERM); 482 493 } 483 484 494 if (chroot(pw->pw_dir) < 0) { 485 495 syslog(LOG_ERR, "%s: %m", pw->pw_dir); … … 493 503 494 504 chdir(ICBD_HOME); 495 505 #endif 496 506 if (setuid(pw->pw_uid) < 0) { 497 507 syslog(LOG_ERR, "%d: %m", pw->pw_uid); … … 499 509 } 500 510 511 #ifdef __OpenBSD__ 501 512 if (dodns) { 502 513 if (pledge("stdio inet rpath dns", NULL) == -1) { … … 510 521 } 511 522 } 523 #endif 512 524 513 525 (void)setproctitle("icbd"); -
logger.c
r2be3612 r4a74b5b 1 1 /* 2 * Copyright (c) 2009 Michael Shalayeff 2 3 * Copyright (c) 2014 Mike Belopuhov 3 * Copyright (c) 2009 Michael Shalayeff 4 * Copyright (c) 2024 Nishi 5 * Copyright (c) 2025 Izuru Yakumo 4 6 * 5 7 * Permission to use, copy, modify, and distribute this software for any … … 96 98 exit(EX_NOUSER); 97 99 } 98 100 #ifdef __OpenBSD 99 101 if (chroot(pw->pw_dir) < 0) { 100 102 syslog(LOG_ERR, "%s: %s: %m", __func__, pw->pw_dir); … … 113 115 exit(EX_NOPERM); 114 116 } 115 117 #endif 118 #ifdef __OpenBSD__ 116 119 if (pledge("stdio cpath wpath", NULL) == -1) { 117 120 syslog(LOG_ERR, "%s: pledge", __func__); 118 121 exit(EX_NOPERM); 119 122 } 123 #endif 120 124 121 125 event_init();
Note:
See TracChangeset
for help on using the changeset viewer.