Changeset 4a74b5b in code


Ignore:
Timestamp:
Apr 17, 2025, 11:33:16 PM (7 weeks ago)
Author:
Izuru Yakumo <eternal-servant@…>
Branches:
master
Parents:
2be3612
Message:

Nitori Engineering

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r2be3612 r4a74b5b  
    11PREFIX?=        /usr/local
    22BINDIR=         ${PREFIX}/sbin
    3 MANDIR=         ${PREFIX}/man/man
     3MANDIR=         ${PREFIX}/man/man8
    44
    55PROG=           icbd
     
    77MAN=            icbd.8
    88
     9.ifdef __OpenBSD__
    910CFLAGS+=        -W -Wall -Werror
    1011CFLAGS+=        -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
    1112CFLAGS+=        -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare
     13.endif
    1214
    1315DPADD=          ${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  
    2828#include <syslog.h>
    2929
     30#ifdef __NetBSD__
     31#define NO_ASYNC
     32#endif
     33
     34#ifdef NO_ASYNC
     35struct asr_result {
     36        struct addrinfo* ar_addrinfo;
     37        int ar_gai_errno;
     38};
     39#else
    3040#include <asr.h>
     41#endif
    3142
    3243#include "icb.h"
     
    8697{
    8798        struct icb_session *is = arg;
     99#ifdef NO_ASYNC
     100        struct asr_result result;
     101#else
    88102        struct asr_query *as;
     103#endif
    89104        struct addrinfo hints;
    90105
     
    100115                memset(&hints, 0, sizeof(hints));
    101116                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
    102122                as = getaddrinfo_async(is->hostname, NULL, &hints, NULL);
    103123                event_asr_run(as, dns_done_host, is);
     124#endif
    104125        } else {
    105126                icbd_log(is, LOG_DEBUG, "reverse dns resolution failed: %s",
     
    130151dns_resolve(struct icb_session *is)
    131152{
     153#ifdef NO_ASYNC
     154        struct asr_result result;
     155#else
    132156        struct asr_query *as;
     157#endif
    133158
    134159        if (!dodns)
     
    140165                icbd_log(is, LOG_DEBUG, "resolving: %s", is->host);
    141166
     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
    142174        as = getnameinfo_async((struct sockaddr *)&is->ss,
    143175            ((struct sockaddr *)&is->ss)->sa_len, is->hostname,
    144176            sizeof is->hostname, NULL, 0, NI_NOFQDN, NULL);
    145177        event_asr_run(as, dns_done_reverse, is);
     178#endif
    146179}
    147180
  • icb.c

    r2be3612 r4a74b5b  
    579579        LIST_FOREACH(s, &ig->sess, entry) {
    580580                (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
    581584                    "%c%c%s%c%lld%c0%c%lld%c%s%c%s%c%s",
     585#endif
    582586                    icb_ismod(ig, s) ? 'm' : ' ', ICB_M_SEP,
    583587                    s->nick, ICB_M_SEP, now - s->last,
  • icbd.c

    r2be3612 r4a74b5b  
    22 * Copyright (c) 2009 Mike Belopuhov
    33 * Copyright (c) 2007 Oleg Safiullin
     4 * Copyright (c) 2024 Nishi
     5 * Copyright (C) 2025 Izuru Yakumo
    46 *
    57 * Permission to use, copy, modify, and distribute this software for any
     
    175177                hints.ai_socktype = SOCK_STREAM;
    176178                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 */
    177183                if ((error = getaddrinfo(addr, port ? port : "icb", &hints,
    178184                    &res0)) != 0) {
     
    180186                        return (EX_UNAVAILABLE);
    181187                }
    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
    183194                for (res = res0; res != NULL; res = res->ai_next) {
    184195                        if ((s = socket(res->ai_family, res->ai_socktype,
     
    476487                exit(EX_NOPERM);
    477488        }
    478 
     489#ifdef __OpenBSD__
    479490        if (sb.st_uid != 0 || (sb.st_mode & (S_IWGRP|S_IWOTH)) != 0) {
    480491                syslog(LOG_ERR, "bad directory permissions");
    481492                exit(EX_NOPERM);
    482493        }
    483 
    484494        if (chroot(pw->pw_dir) < 0) {
    485495                syslog(LOG_ERR, "%s: %m", pw->pw_dir);
     
    493503
    494504        chdir(ICBD_HOME);
    495 
     505#endif
    496506        if (setuid(pw->pw_uid) < 0) {
    497507                syslog(LOG_ERR, "%d: %m", pw->pw_uid);
     
    499509        }
    500510
     511#ifdef __OpenBSD__
    501512        if (dodns) {
    502513                if (pledge("stdio inet rpath dns", NULL) == -1) {
     
    510521                }
    511522        }
     523#endif
    512524
    513525        (void)setproctitle("icbd");
  • logger.c

    r2be3612 r4a74b5b  
    11/*
     2 * Copyright (c) 2009 Michael Shalayeff
    23 * Copyright (c) 2014 Mike Belopuhov
    3  * Copyright (c) 2009 Michael Shalayeff
     4 * Copyright (c) 2024 Nishi
     5 * Copyright (c) 2025 Izuru Yakumo
    46 *
    57 * Permission to use, copy, modify, and distribute this software for any
     
    9698                exit(EX_NOUSER);
    9799        }
    98 
     100#ifdef __OpenBSD
    99101        if (chroot(pw->pw_dir) < 0) {
    100102                syslog(LOG_ERR, "%s: %s: %m", __func__, pw->pw_dir);
     
    113115                exit(EX_NOPERM);
    114116        }
    115 
     117#endif
     118#ifdef __OpenBSD__
    116119        if (pledge("stdio cpath wpath", NULL) == -1) {
    117120                syslog(LOG_ERR, "%s: pledge", __func__);
    118121                exit(EX_NOPERM);
    119122        }
     123#endif
    120124
    121125        event_init();
Note: See TracChangeset for help on using the changeset viewer.