Changeset 4a74b5b in code for icbd.c


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

Nitori Engineering

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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");
Note: See TracChangeset for help on using the changeset viewer.