├── talkd ├── ntalkd.8 ├── talkd.plist.part ├── ntalk.plist ├── extern.h ├── print.c ├── talkd.8 ├── talkd.c ├── announce.c ├── process.c └── table.c ├── wall ├── ttymsg.h ├── wall.plist.part ├── wall.1 └── ttymsg.c ├── telnetd ├── entitlements.plist ├── install_plist.sh ├── telnet.plist ├── telnetd.plist.part ├── generate_plist.sh ├── telnetd.h ├── pathnames.h ├── global.c ├── strlcpy.c ├── authenc.c └── ext.h ├── xcodescripts ├── install-test-files.sh └── install-opensource.sh ├── tftp ├── tftp.plist.part ├── tftp.h └── extern.h ├── logger ├── logger.plist.part └── logger.1 ├── talk ├── talk.plist.part ├── talk_ctl.h ├── get_addrs.c ├── msgs.c ├── talk.c ├── get_iface.c ├── talk.h ├── ctl_transact.c ├── get_names.c ├── look_up.c ├── ctl.c ├── talk.1 ├── io.c ├── display.c ├── invite.c └── init_disp.c ├── tftpd ├── tftpd.plist.part ├── tftp.plist ├── tftp-transfer.h ├── tftp-file.h ├── tftp-io.h ├── tftp-options.h ├── tftp-utils.h └── tftp-file.c ├── telnet ├── telnet.plist.part ├── misc.h ├── general.h ├── fdset.h ├── types.h ├── defines.h ├── authenc.c ├── misc-proto.h ├── ring.h ├── network.c ├── terminal.c └── krb4-proto.h ├── password_enabled.c └── .upstream_base_commits /talkd/ntalkd.8: -------------------------------------------------------------------------------- 1 | .so man8/talkd.8 2 | -------------------------------------------------------------------------------- /wall/ttymsg.h: -------------------------------------------------------------------------------- 1 | /* $FreeBSD$ */ 2 | 3 | #define TTYMSG_IOV_MAX 32 4 | 5 | const char *ttymsg(struct iovec *, int, const char *, int); 6 | -------------------------------------------------------------------------------- /telnetd/entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.network.server 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /xcodescripts/install-test-files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -xue 3 | install -d -m 0755 "$DSTROOT"/AppleInternal/Tests/remote_cmds 4 | install -d -m 0755 \ 5 | "$DSTROOT"/AppleInternal/CoreOS/BATS/unit_tests 6 | tmplist=$(mktemp -t remote_cmds_test_plist) 7 | trap 'rm "$tmplist"' EXIT 8 | xcrun clang -x c -C -P -E -imacros TargetConditionals.h \ 9 | -Wno-invalid-pp-token \ 10 | "$SRCROOT"/tests/remote_cmds.plist.in \ 11 | -o "$tmplist" 12 | plutil -lint "$tmplist" 13 | install -m 0644 "$tmplist" \ 14 | "$DSTROOT"/AppleInternal/CoreOS/BATS/unit_tests/remote_cmds.plist 15 | -------------------------------------------------------------------------------- /telnetd/install_plist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | set -x 4 | 5 | copy_plist() { 6 | mkdir -p "${DSTROOT}/System/Library/LaunchDaemons" 7 | cp "${SCRIPT_INPUT_FILE_0}" "${DSTROOT}/System/Library/LaunchDaemons" 8 | } 9 | 10 | case "$PLATFORM_NAME" in 11 | iphone*|appletv*|watch*|bridge*) 12 | copy_plist 13 | ;; 14 | macosx) 15 | ;; 16 | *) 17 | case "$FALLBACK_PLATFORM_NAME" in 18 | iphone*|appletv*|watch*|bridge*) 19 | copy_plist 20 | ;; 21 | *) 22 | echo "Unsupported platform: $PLATFORM_NAME" 23 | exit 1 24 | ;; 25 | esac 26 | ;; 27 | esac 28 | -------------------------------------------------------------------------------- /wall/wall.plist.part: -------------------------------------------------------------------------------- 1 | 2 | OpenSourceProject 3 | wall 4 | OpenSourceVersion 5 | 2018-04-15 6 | OpenSourceWebsiteURL 7 | https://cgit.freebsd.org/src/tree/usr.bin/wall?id=1a874a126a54fdc188cebd0c58579851c37d1814 8 | OpenSourceImportDate 9 | 2023-05-08 10 | OpenSourceModifications 11 | 12 | ttymsg.c: Return NULL on EBUSY or EACCES 13 | 14 | OpenSourceLicense 15 | BSD 16 | OpenSourceLicenseFile 17 | remote_cmds.txt 18 | 19 | -------------------------------------------------------------------------------- /tftp/tftp.plist.part: -------------------------------------------------------------------------------- 1 | 2 | OpenSourceProject 3 | tftp 4 | OpenSourceVersion 5 | 2023-03-13 6 | OpenSourceWebsiteURL 7 | https://cgit.freebsd.org/src/tree/usr.bin/tftp?id=fc76ddee9be0d7f98c9f9a162627950f8102964e 8 | OpenSourceImportDate 9 | 2023-03-13 10 | OpenSourceModifications 11 | 12 | main.c: -e option 13 | main.c: tsize, tout, blksize commands 14 | 15 | OpenSourceLicense 16 | BSD 17 | OpenSourceLicenseFile 18 | remote_cmds.txt 19 | 20 | -------------------------------------------------------------------------------- /xcodescripts/install-opensource.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Generate and install open source plist 3 | 4 | set -e 5 | 6 | OSV="$DSTROOT"/usr/local/OpenSourceVersions 7 | install -d -m 0755 "$OSV" 8 | 9 | tmplist=$(mktemp -t remote_cmds_osv_plist) 10 | trap 'rm "$tmplist"' EXIT 11 | 12 | ( 13 | echo '' 14 | echo '' 15 | echo '' 16 | echo '' 17 | for plistpart in "$SRCROOT"/*/*.plist.part ; do 18 | cat "$plistpart" 19 | done 20 | echo '' 21 | echo '' 22 | ) >"$tmplist" 23 | 24 | plutil -lint "$tmplist" 25 | install -m 0644 "$tmplist" "$OSV"/remote_cmds.plist 26 | -------------------------------------------------------------------------------- /talkd/talkd.plist.part: -------------------------------------------------------------------------------- 1 | 2 | OpenSourceProject 3 | talkd 4 | OpenSourceVersion 5 | 2005-05-06 6 | OpenSourceWebsiteURL 7 | https://cgit.freebsd.org/src/tree/libexec/talkd?id=b49407ee4376dfbc36a71583f4d5bb54d82ad9f3 8 | OpenSourceImportDate 9 | 2008-03-26 10 | OpenSourceModifications 11 | 12 | process.c: Use utmpx for tty look up 13 | talkd.c: Don't check for super user so talkd can run in sandbox 14 | 15 | OpenSourceLicense 16 | BSD 17 | OpenSourceLicenseFile 18 | remote_cmds.txt 19 | 20 | -------------------------------------------------------------------------------- /talkd/ntalk.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Disabled 6 | 7 | Label 8 | com.apple.ntalkd 9 | ProgramArguments 10 | 11 | /usr/libexec/ntalkd 12 | 13 | inetdCompatibility 14 | 15 | Wait 16 | 17 | 18 | Sockets 19 | 20 | Listeners 21 | 22 | SockServiceName 23 | ntalk 24 | SockType 25 | dgram 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /logger/logger.plist.part: -------------------------------------------------------------------------------- 1 | 2 | OpenSourceProject 3 | logger 4 | OpenSourceVersion 5 | 2023-04-27 6 | OpenSourceWebsiteURL 7 | https://cgit.freebsd.org/src/tree/usr.bin/logger?id=83fd35b3f3fa580d2b99874abd1f67ee61dcb659 8 | OpenSourceImportDate 9 | 2023-05-05 10 | OpenSourceModifications 11 | 12 | logger.c: drop 46AHhPS flags 13 | logger.1: drop 46AHhPS flags 14 | logger.c: log messages to syslog 15 | 16 | OpenSourceLicense 17 | BSD 18 | OpenSourceLicenseFile 19 | remote_cmds.txt 20 | 21 | -------------------------------------------------------------------------------- /talk/talk.plist.part: -------------------------------------------------------------------------------- 1 | 2 | OpenSourceProject 3 | talk 4 | OpenSourceVersion 5 | 2008-02-05 6 | OpenSourceWebsiteURL 7 | https://cgit.freebsd.org/src/tree/usr.bin/logger?id=d870d44d2054d4449b75870fd432a9ab41c0ab58 8 | OpenSourceImportDate 9 | 2008-03-26 10 | OpenSourceModifications 11 | 12 | talk.c: Set process title 13 | ctl_transact.c: use a static count for nfds in select 14 | io.c: use a static count for nfds in select 15 | 16 | OpenSourceLicense 17 | BSD 18 | OpenSourceLicenseFile 19 | remote_cmds.txt 20 | 21 | -------------------------------------------------------------------------------- /tftpd/tftpd.plist.part: -------------------------------------------------------------------------------- 1 | 2 | OpenSourceProject 3 | tftpd 4 | OpenSourceVersion 5 | 2024-05-10 6 | OpenSourceWebsiteURL 7 | https://cgit.freebsd.org/src/tree/libexec/tftpd?id=25945af47e7a1d06c44c8c160045a866e90569ab 8 | OpenSourceImportDate 9 | 2024-05-14 10 | OpenSourceModifications 11 | 12 | tftp-options.c: adjust type of net.inet.udp.maxdgram 13 | tftpd.c: add -i option for backward compatibility 14 | tftpd.c: in secure mode, strip a prefix that matches the chroot dir (125565246) 15 | 16 | OpenSourceLicense 17 | BSD 18 | OpenSourceLicenseFile 19 | remote_cmds.txt 20 | 21 | -------------------------------------------------------------------------------- /tftpd/tftp.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Disabled 6 | 7 | Label 8 | com.apple.tftpd 9 | ProgramArguments 10 | 11 | /usr/libexec/tftpd 12 | -i 13 | /private/tftpboot 14 | 15 | inetdCompatibility 16 | 17 | Wait 18 | 19 | 20 | InitGroups 21 | 22 | Sockets 23 | 24 | Listeners 25 | 26 | SockServiceName 27 | tftp 28 | SockType 29 | dgram 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /telnetd/telnet.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Disabled 6 | 7 | Label 8 | com.apple.telnetd 9 | ProgramArguments 10 | 11 | /usr/libexec/telnetd 12 | 13 | inetdCompatibility 14 | 15 | Wait 16 | 17 | 18 | Sockets 19 | 20 | Listeners 21 | 22 | SockServiceName 23 | telnet 24 | Bonjour 25 | 26 | 27 | 28 | SessionCreate 29 | 30 | EnablePressuredExit 31 | 32 | EnableTransactions 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /telnet/telnet.plist.part: -------------------------------------------------------------------------------- 1 | 2 | OpenSourceProject 3 | telnet 4 | OpenSourceVersion 5 | 2008-02-05 6 | OpenSourceWebsiteURL 7 | https://cgit.freebsd.org/src/tree/usr.bin/telnet?id=8409aedfa67396980986b68417d5e6ef1351b491 8 | OpenSourceImportDate 9 | 2008-03-26 10 | OpenSourceModifications 11 | 12 | telnet.c: (4022837) 13 | commands.c: Drop obsolete RFC 2292 API 14 | commands.c: Use fork rather than vfork 15 | commands.c: telnet goes to MX host when it shouldn't (5760578) 16 | utilities.c: Fix -Wformat-security issues 17 | 18 | OpenSourceLicense 19 | BSD 20 | OpenSourceLicenseFile 21 | remote_cmds.txt 22 | 23 | -------------------------------------------------------------------------------- /telnetd/telnetd.plist.part: -------------------------------------------------------------------------------- 1 | 2 | OpenSourceProject 3 | telnetd 4 | OpenSourceVersion 5 | 2008-02-05 6 | OpenSourceWebsiteURL 7 | https://cgit.freebsd.org/src/tree/libexec/telnetd?id=2e3838552652a5dbb8a6ca0d5b25799f8e90dd98 8 | OpenSourceImportDate 9 | 2008-03-26 10 | OpenSourceModifications 11 | 12 | ext.h: Report version as FreeBSD 13 | sys_term.c: Voicetool doesn't allow double byte character entry (7905033) 14 | termstat.c: Voicetool doesn't allow double byte character entry (7905033) 15 | utility.c: Voicetool doesn't allow double byte character entry (7905033) 16 | 17 | OpenSourceLicense 18 | BSD 19 | OpenSourceLicenseFile 20 | remote_cmds.txt 21 | 22 | -------------------------------------------------------------------------------- /password_enabled.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if !TARGET_OS_OSX 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /* -1 unspecified 10 | * 0 explicitly disabled 11 | * 1 explicitly enabled 12 | */ 13 | int 14 | password_enabled(void) { 15 | os_log_t logger = os_log_create("com.apple.telnetd", "default"); 16 | int rc = -1; 17 | size_t n = 0; 18 | char *buf = NULL; 19 | 20 | if (0 != sysctlbyname("kern.bootargs", NULL, &n, NULL, 0)) { 21 | os_log_error(logger, "Could not get boot-args size"); 22 | goto fin; 23 | } 24 | buf = malloc(n); 25 | if (NULL == buf || 0 != sysctlbyname("kern.bootargs", buf, &n, NULL, 0)) { 26 | os_log_error(logger, "Could not get boot-args"); 27 | goto fin; 28 | } 29 | char *p = strstr(buf, "rdar102068001="); 30 | if (NULL == p) 31 | goto fin; 32 | n = strcspn(p, "="); // = must be present due to previous strstr 33 | char *val = &p[n+1]; 34 | if ('\0' == *val) { 35 | rc = 0; 36 | goto fin; 37 | } 38 | n = strcspn(val, " \t"); 39 | val[n] = '\0'; 40 | rc = (0 == strcasecmp(val, "yes")); 41 | fin: 42 | if (NULL != buf) { 43 | free(buf); 44 | } 45 | os_log_info(logger, "%s = %d", __func__, rc); 46 | return rc; 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /tftpd/tftp-transfer.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause 3 | * 4 | * Copyright (C) 2008 Edwin Groothuis. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | int tftp_send(int peer, uint16_t *block, struct tftp_stats *tp); 29 | int tftp_receive(int peer, uint16_t *block, struct tftp_stats *tp, 30 | struct tftphdr *firstblock, size_t fb_size); 31 | -------------------------------------------------------------------------------- /tftpd/tftp-file.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause 3 | * 4 | * Copyright (C) 2008 Edwin Groothuis. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | int write_init(int fd, FILE *f, const char *mode); 29 | size_t write_file(char *buffer, int count); 30 | int write_close(void); 31 | 32 | int read_init(int fd, FILE *f, const char *mode); 33 | size_t read_file(char *buffer, int count); 34 | int read_close(void); 35 | 36 | int seek_file(off_t offset); 37 | off_t tell_file(void); 38 | 39 | int synchnet(int peer); 40 | -------------------------------------------------------------------------------- /telnetd/generate_plist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | set -x 4 | 5 | enable_debug_telnet_embedded() { 6 | plutil -replace ProgramArguments -json '["/var/personalized_debug/usr/libexec/telnetd","-p","/var/personalized_debug/usr/bin/login"]' "${SCRIPT_OUTPUT_FILE_0}" 7 | plutil -replace Label -string com.apple.telnetd.debug "${SCRIPT_OUTPUT_FILE_0}" 8 | } 9 | 10 | enable_telnet_embedded() { 11 | /usr/libexec/PlistBuddy -x \ 12 | -c "Delete :Disabled" \ 13 | -c "Add :PosixSpawnType string Interactive" \ 14 | -c "Delete :SessionCreate" \ 15 | -c "Set :Sockets:Listeners:Bonjour false" \ 16 | -c "Add :Sockets:Listeners:SockFamily string IPv4" \ 17 | -c "Add :Sockets:Listeners:SockNodeName string localhost" \ 18 | "${SCRIPT_OUTPUT_FILE_0}" 19 | 20 | if [ -n "$dodebug" ]; then 21 | enable_debug_telnet_embedded 22 | fi 23 | } 24 | 25 | enable_telnet_bridgeos() { 26 | /usr/libexec/PlistBuddy -x \ 27 | -c "Delete :Sockets:Listeners:SockNodeName" \ 28 | -c "Delete :Sockets:Listeners:SockFamily" \ 29 | "${SCRIPT_OUTPUT_FILE_0}" 30 | } 31 | 32 | case "$1" in 33 | --debug) 34 | dodebug=1 35 | ;; 36 | esac 37 | 38 | cp "${SCRIPT_INPUT_FILE_0}" "${SCRIPT_OUTPUT_FILE_0}" 39 | case "$PLATFORM_NAME" in 40 | iphone*|appletv*|watch*) 41 | enable_telnet_embedded 42 | ;; 43 | bridge*) 44 | enable_telnet_embedded 45 | enable_telnet_bridgeos 46 | ;; 47 | macosx) 48 | ;; 49 | *) 50 | case "$FALLBACK_PLATFORM_NAME" in 51 | iphone*|appletv*|watch*) 52 | enable_telnet_embedded 53 | ;; 54 | bridge*) 55 | enable_telnet_embedded 56 | enable_telnet_bridgeos 57 | ;; 58 | *) 59 | echo "Unsupported platform: $PLATFORM_NAME" 60 | exit 1 61 | ;; 62 | esac 63 | ;; 64 | esac 65 | -------------------------------------------------------------------------------- /tftp/tftp.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * @(#)extern.h 8.1 (Berkeley) 6/6/93 32 | * $FreeBSD$ 33 | */ 34 | 35 | int recvfile(int peer, char *port, int fd, char *name, char *mode); 36 | int xmitfile(int peer, char *port, int fd, char *name, char *mode); 37 | 38 | extern int verbose; 39 | extern int maxtimeout; 40 | -------------------------------------------------------------------------------- /talk/talk_ctl.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * $FreeBSD$ 32 | * 33 | * @(#)talk_ctl.h 8.1 (Berkeley) 6/6/93 34 | */ 35 | 36 | extern struct sockaddr_in daemon_addr; 37 | extern struct sockaddr_in ctl_addr; 38 | extern struct sockaddr_in my_addr; 39 | extern struct in_addr my_machine_addr; 40 | extern struct in_addr his_machine_addr; 41 | extern u_short daemon_port; 42 | extern int ctl_sockt; 43 | extern CTL_MSG msg; 44 | -------------------------------------------------------------------------------- /tftpd/tftp-io.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause 3 | * 4 | * Copyright (C) 2008 Edwin Groothuis. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | #define RP_NONE 0 29 | #define RP_RECVFROM -1 30 | #define RP_TOOSMALL -2 31 | #define RP_ERROR -3 32 | #define RP_WRONGSOURCE -4 33 | #define RP_TIMEOUT -5 34 | #define RP_TOOBIG -6 35 | 36 | const char *errtomsg(int); 37 | void send_error(int peer, int); 38 | int send_wrq(int peer, char *, char *); 39 | int send_rrq(int peer, char *, char *); 40 | int send_oack(int peer); 41 | int send_ack(int peer, unsigned short); 42 | int send_data(int peer, uint16_t, char *, int); 43 | int receive_packet(int peer, char *, int, struct sockaddr_storage *, int); 44 | 45 | extern struct sockaddr_storage peer_sock; 46 | extern struct sockaddr_storage me_sock; 47 | -------------------------------------------------------------------------------- /tftp/extern.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)extern.h 8.1 (Berkeley) 6/6/93 34 | * $FreeBSD: src/usr.bin/tftp/extern.h,v 1.3 2002/03/22 01:42:33 imp Exp $ 35 | */ 36 | 37 | void recvfile(int, char *, char *); 38 | void xmitfile(int, char *, char *); 39 | -------------------------------------------------------------------------------- /talkd/extern.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 | * 4 | * Copyright (c) 2002 M. Warner Losh 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | * 27 | * $FreeBSD$ 28 | */ 29 | 30 | extern int debug; 31 | extern char hostname[]; 32 | 33 | int announce(CTL_MSG *, const char *); 34 | int delete_invite(u_int32_t); 35 | void do_announce(CTL_MSG *, CTL_RESPONSE *); 36 | CTL_MSG *find_match(CTL_MSG *request); 37 | CTL_MSG *find_request(CTL_MSG *request); 38 | int find_user(const char *name, char *tty); 39 | void insert_table(CTL_MSG *, CTL_RESPONSE *); 40 | int new_id(void); 41 | int print_mesg(const char *, CTL_MSG *, const char *); 42 | void print_request(const char *, CTL_MSG *); 43 | void print_response(const char *, CTL_RESPONSE *); 44 | void process_request(CTL_MSG *mp, CTL_RESPONSE *rp); 45 | void timeout(int sig); 46 | -------------------------------------------------------------------------------- /telnet/misc.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1991, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)misc.h 8.1 (Berkeley) 6/4/93 34 | */ 35 | 36 | extern char *UserNameRequested; 37 | extern char *LocalHostName; 38 | extern char *RemoteHostName; 39 | extern int ConnectedCount; 40 | extern int ReservedPort; 41 | 42 | #include "misc-proto.h" 43 | -------------------------------------------------------------------------------- /telnet/general.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1988, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)general.h 8.1 (Berkeley) 6/6/93 34 | */ 35 | 36 | /* 37 | * Some general definitions. 38 | */ 39 | 40 | 41 | #define numberof(x) (sizeof x/sizeof x[0]) 42 | #define highestof(x) (numberof(x)-1) 43 | 44 | #define ClearElement(x) memset((char *)&x, 0, sizeof x) 45 | #define ClearArray(x) memset((char *)x, 0, sizeof x) 46 | -------------------------------------------------------------------------------- /telnetd/telnetd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1989, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)telnetd.h 8.1 (Berkeley) 6/4/93 34 | * $FreeBSD: src/contrib/telnet/telnetd/telnetd.h,v 1.2 2001/11/30 21:06:38 markm Exp $ 35 | */ 36 | 37 | 38 | #include "defs.h" 39 | #include "ext.h" 40 | 41 | #ifdef DIAGNOSTICS 42 | #define DIAG(a,b) if (diagnostic & (a)) b 43 | #else 44 | #define DIAG(a,b) 45 | #endif 46 | 47 | /* other external variables */ 48 | extern char **environ; 49 | extern const char *altlogin; 50 | -------------------------------------------------------------------------------- /telnet/fdset.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1988, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)fdset.h 8.1 (Berkeley) 6/6/93 34 | */ 35 | 36 | /* 37 | * The following is defined just in case someone should want to run 38 | * this telnet on a 4.2 system. 39 | * 40 | */ 41 | 42 | #ifndef FD_SETSIZE 43 | 44 | #define FD_SET(n, p) ((p)->fds_bits[0] |= (1<<(n))) 45 | #define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1<<(n))) 46 | #define FD_ISSET(n, p) ((p)->fds_bits[0] & (1<<(n))) 47 | #define FD_ZERO(p) ((p)->fds_bits[0] = 0) 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /telnetd/pathnames.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1989, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)pathnames.h 8.1 (Berkeley) 6/4/93 34 | * $FreeBSD: src/contrib/telnet/telnetd/pathnames.h,v 1.3 2001/08/20 12:28:40 markm Exp $ 35 | */ 36 | 37 | #if BSD > 43 38 | 39 | # include 40 | 41 | # ifndef _PATH_LOGIN 42 | # define _PATH_LOGIN "/usr/bin/login" 43 | # endif 44 | 45 | #else 46 | 47 | # define _PATH_TTY "/dev/tty" 48 | # ifndef _PATH_LOGIN 49 | # define _PATH_LOGIN "/bin/login" 50 | # endif 51 | 52 | #endif 53 | 54 | #ifdef BFTPDAEMON 55 | #define BFTPPATH "/usr/ucb/bftp" 56 | #endif /* BFTPDAEMON */ 57 | -------------------------------------------------------------------------------- /telnet/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1988, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)types.h 8.1 (Berkeley) 6/6/93 34 | */ 35 | 36 | typedef struct { 37 | char *modedescriptions; 38 | char modetype; 39 | } Modelist; 40 | 41 | extern Modelist modelist[]; 42 | 43 | typedef struct { 44 | int 45 | system, /* what the current time is */ 46 | echotoggle, /* last time user entered echo character */ 47 | modenegotiated, /* last time operating mode negotiated */ 48 | didnetreceive, /* last time we read data from network */ 49 | gotDM; /* when did we last see a data mark */ 50 | } Clocks; 51 | 52 | extern Clocks clocks; 53 | -------------------------------------------------------------------------------- /telnetd/global.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1989, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | 34 | #if 0 35 | #ifndef lint 36 | static const char sccsid[] = "@(#)global.c 8.1 (Berkeley) 6/4/93"; 37 | #endif /* not lint */ 38 | #endif 39 | #include 40 | __FBSDID("$FreeBSD: src/contrib/telnet/telnetd/global.c,v 1.6 2003/05/04 02:54:49 obrien Exp $"); 41 | 42 | /* 43 | * Allocate global variables. We do this 44 | * by including the header file that defines 45 | * them all as externs, but first we define 46 | * the keyword "extern" to be nothing, so that 47 | * we will actually allocate the space. 48 | */ 49 | 50 | #include "defs.h" 51 | #define extern 52 | #include "ext.h" 53 | -------------------------------------------------------------------------------- /tftpd/tftp-options.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause 3 | * 4 | * Copyright (C) 2008 Edwin Groothuis. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | /* 29 | * Options 30 | */ 31 | 32 | void init_options(void); 33 | uint16_t make_options(int peer, char *buffer, uint16_t size); 34 | int parse_options(int peer, char *buffer, uint16_t size); 35 | 36 | /* Call back functions */ 37 | int option_tsize(int peer, struct tftphdr *, int, struct stat *); 38 | int option_timeout(int peer); 39 | int option_blksize(int peer); 40 | int option_blksize2(int peer); 41 | int option_rollover(int peer); 42 | int option_windowsize(int peer); 43 | 44 | extern int options_extra_enabled; 45 | extern int options_rfc_enabled; 46 | 47 | struct options { 48 | const char *o_type; 49 | char *o_request; 50 | char *o_reply; 51 | int (*o_handler)(int peer); 52 | int rfc; 53 | }; 54 | 55 | extern struct options options[]; 56 | enum opt_enum { 57 | OPT_TSIZE = 0, 58 | OPT_TIMEOUT, 59 | OPT_BLKSIZE, 60 | OPT_BLKSIZE2, 61 | OPT_ROLLOVER, 62 | OPT_WINDOWSIZE, 63 | }; 64 | 65 | #ifdef __APPLE__ 66 | void options_clear_request(enum opt_enum); 67 | #endif /* __APPLE__ */ 68 | int options_set_request(enum opt_enum, const char *, ...) 69 | __printf0like(2, 3); 70 | #ifdef __APPLE__ 71 | void options_clear_reply(enum opt_enum); 72 | #endif /* __APPLE__ */ 73 | int options_set_reply(enum opt_enum, const char *, ...) 74 | __printf0like(2, 3); 75 | -------------------------------------------------------------------------------- /talk/get_addrs.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | __FBSDID("$FreeBSD$"); 35 | 36 | #ifndef lint 37 | static const char sccsid[] = "@(#)get_addrs.c 8.1 (Berkeley) 6/6/93"; 38 | #endif 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "talk.h" 46 | #include "talk_ctl.h" 47 | 48 | void 49 | get_addrs(const char *my_machine_name __unused, const char *his_machine_name) 50 | { 51 | struct hostent *hp; 52 | struct servent *sp; 53 | 54 | msg.pid = htonl(getpid()); 55 | 56 | hp = gethostbyname(his_machine_name); 57 | if (hp == NULL) 58 | errx(1, "%s: %s", his_machine_name, hstrerror(h_errno)); 59 | bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length); 60 | if (get_iface(&his_machine_addr, &my_machine_addr) == -1) 61 | err(1, "failed to find my interface address"); 62 | /* find the server's port */ 63 | sp = getservbyname("ntalk", "udp"); 64 | if (sp == NULL) 65 | errx(1, "ntalk/udp: service is not registered"); 66 | daemon_port = sp->s_port; 67 | } 68 | -------------------------------------------------------------------------------- /telnet/defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1988, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)defines.h 8.1 (Berkeley) 6/6/93 34 | * $FreeBSD: src/contrib/telnet/telnet/defines.h,v 1.2 2001/11/30 21:06:35 markm Exp $ 35 | */ 36 | 37 | #define settimer(x) clocks.x = clocks.system++ 38 | 39 | #define NETADD(c) { *netoring.supply = c; ring_supplied(&netoring, 1); } 40 | #define NET2ADD(c1,c2) { NETADD(c1); NETADD(c2); } 41 | #define NETBYTES() (ring_full_count(&netoring)) 42 | #define NETROOM() (ring_empty_count(&netoring)) 43 | 44 | #define TTYADD(c) if (!(SYNCHing||flushout)) { \ 45 | *ttyoring.supply = c; \ 46 | ring_supplied(&ttyoring, 1); \ 47 | } 48 | #define TTYBYTES() (ring_full_count(&ttyoring)) 49 | #define TTYROOM() (ring_empty_count(&ttyoring)) 50 | 51 | /* Various modes */ 52 | #define MODE_LOCAL_CHARS(m) ((m)&(MODE_EDIT|MODE_TRAPSIG)) 53 | #define MODE_LOCAL_ECHO(m) ((m)&MODE_ECHO) 54 | #define MODE_COMMAND_LINE(m) ((m)==-1) 55 | 56 | #define CONTROL(x) ((x)&0x1f) /* CTRL(x) is not portable */ 57 | -------------------------------------------------------------------------------- /wall/wall.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1989, 1990, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions 6 | .\" are met: 7 | .\" 1. Redistributions of source code must retain the above copyright 8 | .\" notice, this list of conditions and the following disclaimer. 9 | .\" 2. Redistributions in binary form must reproduce the above copyright 10 | .\" notice, this list of conditions and the following disclaimer in the 11 | .\" documentation and/or other materials provided with the distribution. 12 | .\" 3. Neither the name of the University nor the names of its contributors 13 | .\" may be used to endorse or promote products derived from this software 14 | .\" without specific prior written permission. 15 | .\" 16 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | .\" SUCH DAMAGE. 27 | .\" 28 | .\" @(#)wall.1 8.1 (Berkeley) 6/6/93 29 | .\" $FreeBSD$ 30 | .\" 31 | .Dd February 24, 2012 32 | .Dt WALL 1 33 | .Os 34 | .Sh NAME 35 | .Nm wall 36 | .Nd write a message to users 37 | .Sh SYNOPSIS 38 | .Nm 39 | .Op Fl g Ar group 40 | .Op Ar file 41 | .Sh DESCRIPTION 42 | The 43 | .Nm 44 | utility displays the contents of 45 | .Ar file 46 | or, by default, its standard input, on the terminals of all 47 | currently logged in users. 48 | .Pp 49 | Only the super-user can write on the 50 | terminals of users who have chosen 51 | to deny messages or are using a program which 52 | automatically denies messages. 53 | .Bl -tag -width indent 54 | .It Fl g 55 | Send messages to users in this group. 56 | This option may be specified 57 | multiple times, and any user in any of the specified groups will 58 | receive the message. 59 | .El 60 | .Sh SEE ALSO 61 | .Xr mesg 1 , 62 | .Xr talk 1 , 63 | .Xr write 1 , 64 | .Xr shutdown 8 65 | .Sh HISTORY 66 | A 67 | .Nm 68 | command appeared in PWB UNIX. 69 | .Sh BUGS 70 | The sender's 71 | .Ev LC_CTYPE 72 | setting is used to determine which characters are safe to write to a 73 | terminal, not the receiver's (which 74 | .Nm 75 | has no way of knowing). 76 | -------------------------------------------------------------------------------- /telnetd/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998 Todd C. Miller 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #if defined(LIBC_SCCS) && !defined(lint) 31 | #if 0 32 | static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $"; 33 | #endif 34 | #endif /* LIBC_SCCS and not lint */ 35 | #ifndef lint 36 | static const char rcsid[] = 37 | "$FreeBSD: src/lib/libc/string/strlcpy.c,v 1.3 2001/05/24 08:47:41 obrien Exp $"; 38 | #endif 39 | 40 | #include 41 | #include 42 | 43 | /* 44 | * Copy src to string dst of size siz. At most siz-1 characters 45 | * will be copied. Always NUL terminates (unless siz == 0). 46 | * Returns strlen(src); if retval >= siz, truncation occurred. 47 | */ 48 | size_t strlcpy(dst, src, siz) 49 | char *dst; 50 | const char *src; 51 | size_t siz; 52 | { 53 | register char *d = dst; 54 | register const char *s = src; 55 | register size_t n = siz; 56 | 57 | /* Copy as many bytes as will fit */ 58 | if (n != 0 && --n != 0) { 59 | do { 60 | if ((*d++ = *s++) == 0) 61 | break; 62 | } while (--n != 0); 63 | } 64 | 65 | /* Not enough room in dst, add NUL and traverse rest of src */ 66 | if (n == 0) { 67 | if (siz != 0) 68 | *d = '\0'; /* NUL-terminate dst */ 69 | while (*s++) 70 | ; 71 | } 72 | 73 | return(s - src - 1); /* count does not include NUL */ 74 | } 75 | -------------------------------------------------------------------------------- /talk/msgs.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | #ifndef __APPLE__ 35 | __FBSDID("$FreeBSD$"); 36 | 37 | #ifndef lint 38 | static const char sccsid[] = "@(#)msgs.c 8.1 (Berkeley) 6/6/93"; 39 | #endif 40 | #endif /* __APPLE__ */ 41 | 42 | /* 43 | * A package to display what is happening every MSG_INTERVAL seconds 44 | * if we are slow connecting. 45 | */ 46 | 47 | #include 48 | 49 | #include "talk.h" 50 | 51 | #define MSG_INTERVAL 4 52 | 53 | const char *current_state; 54 | int current_line = 0; 55 | 56 | /* ARGSUSED */ 57 | void 58 | disp_msg(int signo __unused) 59 | { 60 | message(current_state); 61 | } 62 | 63 | void 64 | start_msgs(void) 65 | { 66 | struct itimerval itimer; 67 | 68 | message(current_state); 69 | signal(SIGALRM, disp_msg); 70 | itimer.it_value.tv_sec = itimer.it_interval.tv_sec = MSG_INTERVAL; 71 | itimer.it_value.tv_usec = itimer.it_interval.tv_usec = 0; 72 | setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0); 73 | } 74 | 75 | void 76 | end_msgs(void) 77 | { 78 | struct itimerval itimer; 79 | 80 | timerclear(&itimer.it_value); 81 | timerclear(&itimer.it_interval); 82 | setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0); 83 | signal(SIGALRM, SIG_DFL); 84 | } 85 | -------------------------------------------------------------------------------- /telnetd/authenc.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1991, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | 34 | #if 0 35 | #ifndef lint 36 | static const char sccsid[] = "@(#)authenc.c 8.2 (Berkeley) 5/30/95"; 37 | #endif 38 | #endif 39 | #include 40 | __FBSDID("$FreeBSD: src/contrib/telnet/telnetd/authenc.c,v 1.8 2003/05/04 02:54:49 obrien Exp $"); 41 | 42 | #if defined(AUTHENTICATION) || defined(ENCRYPTION) 43 | #include "telnetd.h" 44 | #include 45 | 46 | int 47 | net_write(unsigned char *str, int len) 48 | { 49 | if (nfrontp + len < netobuf + BUFSIZ) { 50 | output_datalen(str, len); 51 | return(len); 52 | } 53 | return(0); 54 | } 55 | 56 | void 57 | net_encrypt(void) 58 | { 59 | #ifdef ENCRYPTION 60 | char *s = (nclearto > nbackp) ? nclearto : nbackp; 61 | if (s < nfrontp && encrypt_output) { 62 | (*encrypt_output)((unsigned char *)s, nfrontp - s); 63 | } 64 | nclearto = nfrontp; 65 | #endif /* ENCRYPTION */ 66 | } 67 | 68 | int 69 | telnet_spin(void) 70 | { 71 | ttloop(); 72 | return(0); 73 | } 74 | 75 | char * 76 | telnet_getenv(char *val) 77 | { 78 | return(getenv(val)); 79 | } 80 | 81 | char * 82 | telnet_gets(const char *prompt __unused, char *result __unused, int length __unused, int echo __unused) 83 | { 84 | return(NULL); 85 | } 86 | #endif /* ENCRYPTION */ 87 | #endif /* AUTHENTICATION */ 88 | -------------------------------------------------------------------------------- /talk/talk.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | #ifndef __APPLE__ 35 | __FBSDID("$FreeBSD$"); 36 | 37 | #ifndef lint 38 | static const char sccsid[] = "@(#)talk.c 8.1 (Berkeley) 6/6/93"; 39 | #endif 40 | #endif /* __APPLE__ */ 41 | 42 | #ifndef lint 43 | __attribute__((__used__)) 44 | static const char copyright[] = 45 | "@(#) Copyright (c) 1983, 1993\n\ 46 | The Regents of the University of California. All rights reserved.\n"; 47 | #endif 48 | 49 | #include 50 | #include 51 | 52 | #include "talk.h" 53 | 54 | /* 55 | * talk: A visual form of write. Using sockets, a two way 56 | * connection is set up between the two people talking. 57 | * With the aid of curses, the screen is split into two 58 | * windows, and each users text is added to the window, 59 | * one character at a time... 60 | * 61 | * Written by Kipp Hickman 62 | * 63 | * Modified to run under 4.1a by Clem Cole and Peter Moore 64 | * Modified to run between hosts by Peter Moore, 8/19/82 65 | * Modified to run under 4.1c by Peter Moore 3/17/83 66 | * Fixed to not run with unwriteable terminals MRVM 28/12/94 67 | */ 68 | 69 | int 70 | main(int argc, char **argv) 71 | { 72 | (void) setlocale(LC_CTYPE, ""); 73 | 74 | get_names(argc, argv); 75 | #ifndef __APPLE__ 76 | setproctitle(" "); 77 | #endif 78 | check_writeable(); 79 | init_display(); 80 | open_ctl(); 81 | open_sockt(); 82 | start_msgs(); 83 | if (!check_local()) 84 | invite_remote(); 85 | end_msgs(); 86 | set_edit_chars(); 87 | talk(); 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /talk/get_iface.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1994, 1995 Massachusetts Institute of Technology 3 | * 4 | * Permission to use, copy, modify, and distribute this software and 5 | * its documentation for any purpose and without fee is hereby 6 | * granted, provided that both the above copyright notice and this 7 | * permission notice appear in all copies, that both the above 8 | * copyright notice and this permission notice appear in all 9 | * supporting documentation, and that the name of M.I.T. not be used 10 | * in advertising or publicity pertaining to distribution of the 11 | * software without specific, written prior permission. M.I.T. makes 12 | * no representations about the suitability of this software for any 13 | * purpose. It is provided "as is" without express or implied 14 | * warranty. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS 17 | * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, 18 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT 20 | * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 23 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 26 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #include 31 | 32 | #ifndef __APPLE__ 33 | __FBSDID("$FreeBSD$"); 34 | #endif 35 | 36 | /* 37 | * From: 38 | * Id: find_interface.c,v 1.1 1995/08/14 16:08:39 wollman Exp 39 | */ 40 | 41 | #include 42 | #include 43 | #include 44 | 45 | #include "talk.h" 46 | 47 | /* 48 | * Try to find the interface address that is used to route an IP 49 | * packet to a remote peer. 50 | */ 51 | 52 | int 53 | get_iface(struct in_addr *dst, struct in_addr *iface) 54 | { 55 | static struct sockaddr_in local; 56 | struct sockaddr_in remote; 57 | socklen_t namelen; 58 | int s, rv; 59 | 60 | memcpy(&remote.sin_addr, dst, sizeof remote.sin_addr); 61 | remote.sin_port = htons(60000); 62 | remote.sin_family = AF_INET; 63 | remote.sin_len = sizeof remote; 64 | 65 | local.sin_addr.s_addr = htonl(INADDR_ANY); 66 | local.sin_port = htons(60000); 67 | local.sin_family = AF_INET; 68 | local.sin_len = sizeof local; 69 | 70 | s = socket(PF_INET, SOCK_DGRAM, 0); 71 | if (s < 0) 72 | return -1; 73 | 74 | do { 75 | rv = bind(s, (struct sockaddr *)&local, sizeof local); 76 | local.sin_port = htons(ntohs(local.sin_port) + 1); 77 | } while(rv < 0 && errno == EADDRINUSE); 78 | 79 | if (rv < 0) { 80 | close(s); 81 | return -1; 82 | } 83 | 84 | do { 85 | rv = connect(s, (struct sockaddr *)&remote, sizeof remote); 86 | remote.sin_port = htons(ntohs(remote.sin_port) + 1); 87 | } while(rv < 0 && errno == EADDRINUSE); 88 | 89 | if (rv < 0) { 90 | close(s); 91 | return -1; 92 | } 93 | 94 | namelen = sizeof local; 95 | rv = getsockname(s, (struct sockaddr *)&local, &namelen); 96 | close(s); 97 | if (rv < 0) 98 | return -1; 99 | 100 | memcpy(iface, &local.sin_addr, sizeof local.sin_addr); 101 | return 0; 102 | } 103 | -------------------------------------------------------------------------------- /talkd/print.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | #if 0 34 | static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 6/4/93"; 35 | #endif 36 | __attribute__((__used__)) 37 | static const char rcsid[] = 38 | "$FreeBSD$"; 39 | #endif /* not lint */ 40 | 41 | /* debug print routines */ 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | #include "extern.h" 51 | 52 | static const char *types[] = 53 | { "leave_invite", "look_up", "delete", "announce" }; 54 | #define NTYPES (sizeof (types) / sizeof (types[0])) 55 | static const char *answers[] = 56 | { "success", "not_here", "failed", "machine_unknown", "permission_denied", 57 | "unknown_request", "badversion", "badaddr", "badctladdr" }; 58 | #define NANSWERS (sizeof (answers) / sizeof (answers[0])) 59 | 60 | void 61 | print_request(const char *cp, CTL_MSG *mp) 62 | { 63 | const char *tp; 64 | char tbuf[80]; 65 | 66 | if (mp->type > NTYPES) { 67 | (void)snprintf(tbuf, sizeof(tbuf), "type %d", mp->type); 68 | tp = tbuf; 69 | } else 70 | tp = types[mp->type]; 71 | syslog(LOG_DEBUG, "%s: %s: id %lu, l_user %s, r_user %s, r_tty %s", 72 | cp, tp, (long)mp->id_num, mp->l_name, mp->r_name, mp->r_tty); 73 | } 74 | 75 | void 76 | print_response(const char *cp, CTL_RESPONSE *rp) 77 | { 78 | const char *tp, *ap; 79 | char tbuf[80], abuf[80]; 80 | 81 | if (rp->type > NTYPES) { 82 | (void)snprintf(tbuf, sizeof(tbuf), "type %d", rp->type); 83 | tp = tbuf; 84 | } else 85 | tp = types[rp->type]; 86 | if (rp->answer > NANSWERS) { 87 | (void)snprintf(abuf, sizeof(abuf), "answer %d", rp->answer); 88 | ap = abuf; 89 | } else 90 | ap = answers[rp->answer]; 91 | syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num)); 92 | } 93 | -------------------------------------------------------------------------------- /talkd/talkd.8: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1983, 1991, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions 6 | .\" are met: 7 | .\" 1. Redistributions of source code must retain the above copyright 8 | .\" notice, this list of conditions and the following disclaimer. 9 | .\" 2. Redistributions in binary form must reproduce the above copyright 10 | .\" notice, this list of conditions and the following disclaimer in the 11 | .\" documentation and/or other materials provided with the distribution. 12 | .\" 3. Neither the name of the University nor the names of its contributors 13 | .\" may be used to endorse or promote products derived from this software 14 | .\" without specific prior written permission. 15 | .\" 16 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | .\" SUCH DAMAGE. 27 | .\" 28 | .\" @(#)talkd.8 8.2 (Berkeley) 12/11/93 29 | .\" $FreeBSD$ 30 | .\" 31 | .Dd August 21, 2008 32 | .Dt TALKD 8 33 | .Os 34 | .Sh NAME 35 | .Nm talkd 36 | .Nd remote user communication server 37 | .Sh SYNOPSIS 38 | .Nm 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | utility 43 | is the server that notifies a user that someone else wants to 44 | initiate a conversation. 45 | It acts as a repository of invitations, responding to requests 46 | by clients wishing to rendezvous to hold a conversation. 47 | In normal operation, a client, the caller, 48 | initiates a rendezvous by sending a 49 | .Tn CTL_MSG 50 | to the server of 51 | type 52 | .Tn LOOK_UP 53 | (see 54 | .In protocols/talkd.h ) . 55 | This causes the server to search its invitation 56 | tables to check if an invitation currently exists for the caller 57 | (to speak to the callee specified in the message). 58 | .Pp 59 | If the lookup fails, 60 | the caller then sends an 61 | .Tn ANNOUNCE 62 | message causing the server to 63 | broadcast an announcement on the callee's login ports requesting contact. 64 | .Pp 65 | When the callee responds, the local server uses the 66 | recorded invitation to respond with the appropriate rendezvous 67 | address and the caller and callee client programs establish a 68 | stream connection through which the conversation takes place. 69 | .Sh CONFIGURATION 70 | The 71 | .Nm 72 | utility is managed by 73 | .Xr launchd 8 74 | as specified in the 75 | .Pa ntalk.plist 76 | property list. 77 | By default the property list contains the 78 | .Em Disabled 79 | key set to true, so 80 | .Nm 81 | is never invoked. 82 | .Pp 83 | Execute the following command as root to enable 84 | .Nm talkd : 85 | .Dl "launchctl load -w /System/Library/LaunchDaemons/ntalk.plist" 86 | .Pp 87 | .Sh SEE ALSO 88 | .Xr talk 1 , 89 | .Xr write 1 90 | .Sh HISTORY 91 | The 92 | .Nm 93 | utility appeared in 94 | .Bx 4.3 . 95 | -------------------------------------------------------------------------------- /logger/logger.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1983, 1990, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions 6 | .\" are met: 7 | .\" 1. Redistributions of source code must retain the above copyright 8 | .\" notice, this list of conditions and the following disclaimer. 9 | .\" 2. Redistributions in binary form must reproduce the above copyright 10 | .\" notice, this list of conditions and the following disclaimer in the 11 | .\" documentation and/or other materials provided with the distribution. 12 | .\" 3. Neither the name of the University nor the names of its contributors 13 | .\" may be used to endorse or promote products derived from this software 14 | .\" without specific prior written permission. 15 | .\" 16 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | .\" SUCH DAMAGE. 27 | .\" 28 | .\" @(#)logger.1 8.1 (Berkeley) 6/6/93 29 | .\" $FreeBSD$ 30 | .\" 31 | .Dd March 16, 2022 32 | .Dt LOGGER 1 33 | .Os 34 | .Sh NAME 35 | .Nm logger 36 | .Nd make entries in the system log 37 | .Sh SYNOPSIS 38 | .Nm 39 | .Op Fl is 40 | .Op Fl f Ar file 41 | .Op Fl p Ar pri 42 | .Op Fl t Ar tag 43 | .Op Ar message ... 44 | .Sh DESCRIPTION 45 | The 46 | .Nm 47 | utility provides a shell command interface to the 48 | .Xr syslog 3 49 | system log module. 50 | .Pp 51 | The following options are available: 52 | .Bl -tag -width indent 53 | .It Fl i 54 | Log the process id of the logger process 55 | with each line. 56 | This flag is ignored and the process id is always logged. 57 | .It Fl s 58 | Log the message to standard error, as well as the system log. 59 | .It Fl f Ar file 60 | Read the contents of the specified file into syslog. 61 | This option is ignored when a message is also specified. 62 | .It Fl p Ar pri 63 | Enter the message with the specified priority. 64 | The priority may be specified numerically or as a 65 | .Li facility.level 66 | pair. 67 | For example, 68 | .Dq Fl p Li local3.info 69 | logs the message(s) as 70 | .Ar info Ns rmational 71 | level in the 72 | .Ar local3 73 | facility. 74 | The default is 75 | .Dq Li user.notice . 76 | .It Fl t Ar tag 77 | Mark every line in the log with the specified 78 | .Ar tag 79 | rather than the default of current login name. 80 | .It Ar message 81 | Write the message to log; if not specified, and the 82 | .Fl f 83 | flag is not 84 | provided, standard input is logged. 85 | .El 86 | .Sh EXIT STATUS 87 | .Ex -std 88 | .Sh EXAMPLES 89 | .Bd -literal -offset indent -compact 90 | logger System rebooted 91 | 92 | logger \-p local0.notice \-t HOSTIDM \-f /dev/idmc 93 | .Ed 94 | .Sh SEE ALSO 95 | .Xr syslog 3 , 96 | .Xr syslogd 8 97 | .Sh STANDARDS 98 | The 99 | .Nm 100 | command is expected to be 101 | .St -p1003.2 102 | compatible. 103 | -------------------------------------------------------------------------------- /telnet/authenc.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1991, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | 34 | #if 0 35 | #ifndef lint 36 | static const char sccsid[] = "@(#)authenc.c 8.1 (Berkeley) 6/6/93"; 37 | #endif 38 | #endif 39 | #include 40 | __FBSDID("$FreeBSD: src/contrib/telnet/telnet/authenc.c,v 1.6 2003/05/04 02:54:48 obrien Exp $"); 41 | 42 | #ifdef AUTHENTICATION 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | #include "general.h" 51 | #include "ring.h" 52 | #include "externs.h" 53 | #include "defines.h" 54 | #include "types.h" 55 | 56 | int 57 | net_write(unsigned char *str, int len) 58 | { 59 | if (NETROOM() > len) { 60 | ring_supply_data(&netoring, str, len); 61 | if (str[0] == IAC && str[1] == SE) 62 | printsub('>', &str[2], len-2); 63 | return(len); 64 | } 65 | return(0); 66 | } 67 | 68 | void 69 | net_encrypt(void) 70 | { 71 | #ifdef ENCRYPTION 72 | if (encrypt_output) 73 | ring_encrypt(&netoring, encrypt_output); 74 | else 75 | ring_clearto(&netoring); 76 | #endif /* ENCRYPTION */ 77 | } 78 | 79 | int 80 | telnet_spin(void) 81 | { 82 | return(-1); 83 | } 84 | 85 | char * 86 | telnet_getenv(char *val) 87 | { 88 | return((char *)env_getvalue((unsigned char *)val)); 89 | } 90 | 91 | char * 92 | telnet_gets(const char *prom, char *result, int length, int echo) 93 | { 94 | extern int globalmode; 95 | int om = globalmode; 96 | char *res; 97 | 98 | TerminalNewMode(-1); 99 | if (echo) { 100 | printf("%s", prom); 101 | res = fgets(result, length, stdin); 102 | } else if ((res = getpass(prom))) { 103 | strncpy(result, res, length); 104 | res = result; 105 | } 106 | TerminalNewMode(om); 107 | return(res); 108 | } 109 | #endif /* AUTHENTICATION */ 110 | -------------------------------------------------------------------------------- /talk/talk.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * @(#)talk.h 8.1 (Berkeley) 6/6/93 32 | * $FreeBSD$ 33 | */ 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #ifdef __APPLE__ 42 | /* remove if / when Libc/include/protocols/talkd is updated */ 43 | #define tsockaddr osockaddr 44 | #endif /* __APPLE__ */ 45 | #include 46 | #include 47 | #include 48 | 49 | extern int sockt; 50 | extern int curses_initialized; 51 | extern int invitation_waiting; 52 | 53 | extern const char *current_state; 54 | extern int current_line; 55 | 56 | extern volatile sig_atomic_t gotwinch; 57 | 58 | typedef struct xwin { 59 | WINDOW *x_win; 60 | int x_nlines; 61 | int x_ncols; 62 | int x_line; 63 | int x_col; 64 | char kill; 65 | char cerase; 66 | char werase; 67 | } xwin_t; 68 | 69 | extern xwin_t my_win; 70 | extern xwin_t his_win; 71 | extern WINDOW *line_win; 72 | 73 | extern void announce_invite(void); 74 | extern int check_local(void); 75 | extern void check_writeable(void); 76 | extern void ctl_transact(struct in_addr,CTL_MSG,int,CTL_RESPONSE *); 77 | extern void disp_msg(int); 78 | extern void end_msgs(void); 79 | extern void get_addrs(const char *, const char *); 80 | extern int get_iface(struct in_addr *, struct in_addr *); 81 | extern void get_names(int, char **); 82 | extern void init_display(void); 83 | extern void invite_remote(void); 84 | extern int look_for_invite(CTL_RESPONSE *); 85 | extern int max(int, int); 86 | extern void message(const char *); 87 | extern void open_ctl(void); 88 | extern void open_sockt(void); 89 | extern void p_error(const char *); 90 | extern void print_addr(struct sockaddr_in); 91 | extern void quit(void); 92 | extern int readwin(WINDOW *, int, int); 93 | extern void re_invite(int); 94 | extern void send_delete(void); 95 | extern void set_edit_chars(void); 96 | extern void sig_sent(int); 97 | extern void sig_winch(int); 98 | extern void start_msgs(void); 99 | extern void talk(void); 100 | extern void resize_display(void); 101 | -------------------------------------------------------------------------------- /telnet/misc-proto.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1991, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)misc-proto.h 8.1 (Berkeley) 6/4/93 34 | * $FreeBSD: src/crypto/telnet/libtelnet/misc-proto.h,v 1.1.1.1.8.1 2002/04/13 10:59:07 markm Exp $ 35 | */ 36 | 37 | /* 38 | * Copyright (C) 1990 by the Massachusetts Institute of Technology 39 | * 40 | * Export of this software from the United States of America is assumed 41 | * to require a specific license from the United States Government. 42 | * It is the responsibility of any person or organization contemplating 43 | * export to obtain such a license before exporting. 44 | * 45 | * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 46 | * distribute this software and its documentation for any purpose and 47 | * without fee is hereby granted, provided that the above copyright 48 | * notice appear in all copies and that both that copyright notice and 49 | * this permission notice appear in supporting documentation, and that 50 | * the name of M.I.T. not be used in advertising or publicity pertaining 51 | * to distribution of the software without specific, written prior 52 | * permission. M.I.T. makes no representations about the suitability of 53 | * this software for any purpose. It is provided "as is" without express 54 | * or implied warranty. 55 | */ 56 | 57 | #ifndef __MISC_PROTO__ 58 | #define __MISC_PROTO__ 59 | 60 | void auth_encrypt_init(char *, char *, const char *, int); 61 | void auth_encrypt_connect(int); 62 | void printd(const unsigned char *, int); 63 | 64 | int isprefix(char *, const char *); 65 | char **genget(char *, char **, int); 66 | int Ambiguous(char **); 67 | 68 | int getent(char *, const char *); 69 | char *Getstr(const char *, char **); 70 | 71 | /* 72 | * These functions are imported from the application 73 | */ 74 | int net_write(unsigned char *, int); 75 | void net_encrypt(void); 76 | int telnet_spin(void); 77 | char *telnet_getenv(char *); 78 | char *telnet_gets(const char *, char *, int, int); 79 | void printsub(char, unsigned char *, int); 80 | #endif 81 | -------------------------------------------------------------------------------- /talk/ctl_transact.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | #ifndef __APPLE__ 35 | __FBSDID("$FreeBSD$"); 36 | 37 | #ifndef lint 38 | static const char sccsid[] = "@(#)ctl_transact.c 8.1 (Berkeley) 6/6/93"; 39 | #endif 40 | #endif /* __APPLE__ */ 41 | 42 | #include 43 | 44 | #include 45 | #include 46 | 47 | #include "talk.h" 48 | #include "talk_ctl.h" 49 | 50 | #define CTL_WAIT 2 /* time to wait for a response, in seconds */ 51 | 52 | /* 53 | * SOCKDGRAM is unreliable, so we must repeat messages if we have 54 | * not received an acknowledgement within a reasonable amount 55 | * of time 56 | */ 57 | void 58 | ctl_transact(struct in_addr target, CTL_MSG lmsg, int type, CTL_RESPONSE *rp) 59 | { 60 | struct pollfd pfd[1]; 61 | int nready = 0, cc; 62 | 63 | lmsg.type = type; 64 | daemon_addr.sin_addr = target; 65 | daemon_addr.sin_port = daemon_port; 66 | pfd[0].fd = ctl_sockt; 67 | pfd[0].events = POLLIN; 68 | 69 | /* 70 | * Keep sending the message until a response of 71 | * the proper type is obtained. 72 | */ 73 | do { 74 | /* resend message until a response is obtained */ 75 | do { 76 | cc = sendto(ctl_sockt, (char *)&lmsg, sizeof (lmsg), 0, 77 | (struct sockaddr *)&daemon_addr, 78 | sizeof (daemon_addr)); 79 | if (cc != sizeof (lmsg)) { 80 | if (errno == EINTR) 81 | continue; 82 | p_error("Error on write to talk daemon"); 83 | } 84 | nready = poll(pfd, 1, CTL_WAIT * 1000); 85 | if (nready < 0) { 86 | if (errno == EINTR) 87 | continue; 88 | p_error("Error waiting for daemon response"); 89 | } 90 | } while (nready == 0); 91 | /* 92 | * Keep reading while there are queued messages 93 | * (this is not necessary, it just saves extra 94 | * request/acknowledgements being sent) 95 | */ 96 | do { 97 | cc = recv(ctl_sockt, (char *)rp, sizeof (*rp), 0); 98 | if (cc < 0) { 99 | if (errno == EINTR) 100 | continue; 101 | p_error("Error on read from talk daemon"); 102 | } 103 | nready = poll(pfd, 1, 0); 104 | } while (nready > 0 && (rp->vers != TALK_VERSION || 105 | rp->type != type)); 106 | } while (rp->vers != TALK_VERSION || rp->type != type); 107 | rp->id_num = ntohl(rp->id_num); 108 | rp->addr.sa_family = ntohs(rp->addr.sa_family); 109 | } 110 | -------------------------------------------------------------------------------- /talk/get_names.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | #ifndef __APPLE__ 35 | __FBSDID("$FreeBSD$"); 36 | 37 | #ifndef lint 38 | static const char sccsid[] = "@(#)get_names.c 8.1 (Berkeley) 6/6/93"; 39 | #endif 40 | #endif /* __APPLE__ */ 41 | 42 | #include 43 | 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | #include "talk.h" 51 | 52 | extern CTL_MSG msg; 53 | 54 | static void 55 | usage(void) 56 | { 57 | fprintf(stderr, "usage: talk person [ttyname]\n"); 58 | exit(1); 59 | } 60 | 61 | /* 62 | * Determine the local and remote user, tty, and machines 63 | */ 64 | void 65 | get_names(int argc, char *argv[]) 66 | { 67 | char hostname[MAXHOSTNAMELEN]; 68 | char *his_name, *my_name; 69 | const char *my_machine_name, *his_machine_name; 70 | const char *his_tty; 71 | char *cp; 72 | 73 | if (argc < 2 ) 74 | usage(); 75 | if (!isatty(0)) 76 | errx(1, "standard input must be a tty, not a pipe or a file"); 77 | if ((my_name = getlogin()) == NULL) { 78 | struct passwd *pw; 79 | 80 | if ((pw = getpwuid(getuid())) == NULL) 81 | errx(1, "you don't exist. Go away"); 82 | my_name = pw->pw_name; 83 | } 84 | gethostname(hostname, sizeof (hostname)); 85 | my_machine_name = hostname; 86 | /* check for, and strip out, the machine name of the target */ 87 | cp = argv[1] + strcspn(argv[1], "@:!"); 88 | if (*cp == '\0') { 89 | /* this is a local to local talk */ 90 | his_name = argv[1]; 91 | my_machine_name = his_machine_name = "localhost"; 92 | } else { 93 | if (*cp++ == '@') { 94 | /* user@host */ 95 | his_name = argv[1]; 96 | his_machine_name = cp; 97 | } else { 98 | /* host!user or host:user */ 99 | his_name = cp; 100 | his_machine_name = argv[1]; 101 | } 102 | *--cp = '\0'; 103 | } 104 | if (argc > 2) 105 | his_tty = argv[2]; /* tty name is arg 2 */ 106 | else 107 | his_tty = ""; 108 | get_addrs(my_machine_name, his_machine_name); 109 | /* 110 | * Initialize the message template. 111 | */ 112 | msg.vers = TALK_VERSION; 113 | msg.addr.sa_family = htons(AF_INET); 114 | msg.ctl_addr.sa_family = htons(AF_INET); 115 | msg.id_num = htonl(0); 116 | strlcpy(msg.l_name, my_name, NAME_SIZE); 117 | strlcpy(msg.r_name, his_name, NAME_SIZE); 118 | strlcpy(msg.r_tty, his_tty, TTY_SIZE); 119 | } 120 | -------------------------------------------------------------------------------- /telnet/ring.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1988, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)ring.h 8.1 (Berkeley) 6/6/93 34 | * $FreeBSD: src/contrib/telnet/telnet/ring.h,v 1.4 2001/11/30 22:28:07 markm Exp $ 35 | */ 36 | 37 | #if defined(P) 38 | # undef P 39 | #endif 40 | 41 | #if defined(__STDC__) || defined(LINT_ARGS) 42 | # define P(x) x 43 | #else 44 | # define P(x) () 45 | #endif 46 | 47 | /* 48 | * This defines a structure for a ring buffer. 49 | * 50 | * The circular buffer has two parts: 51 | *((( 52 | * full: [consume, supply) 53 | * empty: [supply, consume) 54 | *]]] 55 | * 56 | */ 57 | typedef struct { 58 | unsigned char *consume, /* where data comes out of */ 59 | *supply, /* where data comes in to */ 60 | *bottom, /* lowest address in buffer */ 61 | *top, /* highest address+1 in buffer */ 62 | *mark; /* marker (user defined) */ 63 | #ifdef ENCRYPTION 64 | unsigned char *clearto; /* Data to this point is clear text */ 65 | unsigned char *encryyptedto; /* Data is encrypted to here */ 66 | #endif /* ENCRYPTION */ 67 | int size; /* size in bytes of buffer */ 68 | u_long consumetime, /* help us keep straight full, empty, etc. */ 69 | supplytime; 70 | } Ring; 71 | 72 | /* Here are some functions and macros to deal with the ring buffer */ 73 | 74 | /* Initialization routine */ 75 | extern int 76 | ring_init(Ring *ring, unsigned char *buffer, int count); 77 | 78 | /* Data movement routines */ 79 | extern void 80 | ring_supply_data(Ring *ring, unsigned char *buffer, int count); 81 | #ifdef notdef 82 | extern void 83 | ring_consume_data(Ring *ring, unsigned char *buffer, int count); 84 | #endif 85 | 86 | /* Buffer state transition routines */ 87 | extern void 88 | ring_supplied(Ring *ring, int count), 89 | ring_consumed(Ring *ring, int count); 90 | 91 | /* Buffer state query routines */ 92 | extern int 93 | ring_at_mark(Ring *), 94 | ring_empty_count(Ring *ring), 95 | ring_empty_consecutive(Ring *ring), 96 | ring_full_count(Ring *ring), 97 | ring_full_consecutive(Ring *ring); 98 | 99 | #ifdef ENCRYPTION 100 | extern void 101 | ring_encrypt(Ring *ring, void (*func)(unsigned char *, int)), 102 | ring_clearto(Ring *ring); 103 | #endif /* ENCRYPTION */ 104 | 105 | extern void 106 | ring_clear_mark(Ring *), 107 | ring_mark(Ring *); 108 | -------------------------------------------------------------------------------- /.upstream_base_commits: -------------------------------------------------------------------------------- 1 | #freebsd = https://git.FreeBSD.org/src.git 2 | 3 | logger/logger.1 freebsd usr.bin/logger/logger.1 4bbc8ee29e6893d1b15f39b8857ffe45609293b9 4 | logger/logger.c freebsd usr.bin/logger/logger.c 83fd35b3f3fa580d2b99874abd1f67ee61dcb659 5 | 6 | talk/ctl.c freebsd usr.bin/talk/ctl.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 7 | talk/ctl_transact.c freebsd usr.bin/talk/ctl_transact.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 8 | talk/display.c freebsd usr.bin/talk/display.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 9 | talk/get_addrs.c freebsd usr.bin/talk/get_addrs.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 10 | talk/get_iface.c freebsd usr.bin/talk/get_iface.c 3daadfc83361cf4f31017a7fed5a5910cd8c4ce9 11 | talk/get_names.c freebsd usr.bin/talk/get_names.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 12 | talk/init_disp.c freebsd usr.bin/talk/init_disp.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 13 | talk/invite.c freebsd usr.bin/talk/invite.c e4478d7e46876142b5f75cfc93ef649a6bde05ae 14 | talk/io.c freebsd usr.bin/talk/io.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 15 | talk/look_up.c freebsd usr.bin/talk/look_up.c e4478d7e46876142b5f75cfc93ef649a6bde05ae 16 | talk/msgs.c freebsd usr.bin/talk/msgs.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 17 | talk/talk.1 freebsd usr.bin/talk/talk.1 fbbd9655e5107c68e4e0146ff22b73d7350475bc 18 | talk/talk.c freebsd usr.bin/talk/talk.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 19 | talk/talk.h freebsd usr.bin/talk/talk.h 8a16b7a18f5d0b031f09832fd7752fba717e2a97 20 | talk/talk_ctl.h freebsd usr.bin/talk/talk_ctl.h 8a16b7a18f5d0b031f09832fd7752fba717e2a97 21 | 22 | talkd/announce.c freebsd libexec/talkd/announce.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 23 | talkd/extern.h freebsd libexec/talkd/extern.h f86e60008bdf690b61af2c18e98ee791ca91433f 24 | talkd/print.c freebsd libexec/talkd/print.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 25 | talkd/process.c freebsd libexec/talkd/process.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 26 | talkd/table.c freebsd libexec/talkd/table.c 8a16b7a18f5d0b031f09832fd7752fba717e2a97 27 | talkd/talkd.8 freebsd libexec/talkd/talkd.8 5efaea4cc6095b61e0df2a8bc7fd9912c019d805 28 | talkd/talkd.c freebsd libexec/talkd/talkd.c e4478d7e46876142b5f75cfc93ef649a6bde05ae 29 | 30 | tftp/main.c freebsd usr.bin/tftp/main.c 92570f67c7911126ce742a3dfe1b97046091ed0e 31 | tftp/tftp.1 freebsd usr.bin/tftp/tftp.1 1c7a40d268e716559ebbdec22f1778a6f75d096f 32 | tftp/tftp.c freebsd usr.bin/tftp/tftp.c 92570f67c7911126ce742a3dfe1b97046091ed0e 33 | tftp/tftp.h freebsd usr.bin/tftp/tftp.h 92570f67c7911126ce742a3dfe1b97046091ed0e 34 | tftp/tests/tftp_test.sh freebsd usr.bin/tftp/tests/tftp_test.sh fc76ddee9be0d7f98c9f9a162627950f8102964e 35 | 36 | tftpd/tftp-file.c freebsd libexec/tftpd/tftp-file.c a6fe717c2a876105123214c05176cd74106fb94b 37 | tftpd/tftp-file.h freebsd libexec/tftpd/tftp-file.h 1111da6b7c612c571453a23a8dd02fd5e7e40b18 38 | tftpd/tftp-io.c freebsd libexec/tftpd/tftp-io.c 4d09eb87c5d5bec2e2832f50537e2ce6f75f4117 39 | tftpd/tftp-io.h freebsd libexec/tftpd/tftp-io.h 1111da6b7c612c571453a23a8dd02fd5e7e40b18 40 | tftpd/tftp-options.c freebsd libexec/tftpd/tftp-options.c a6fe717c2a876105123214c05176cd74106fb94b 41 | tftpd/tftp-options.h freebsd libexec/tftpd/tftp-options.h 1111da6b7c612c571453a23a8dd02fd5e7e40b18 42 | tftpd/tftp-transfer.c freebsd libexec/tftpd/tftp-transfer.c a6fe717c2a876105123214c05176cd74106fb94b 43 | tftpd/tftp-transfer.h freebsd libexec/tftpd/tftp-transfer.h 1111da6b7c612c571453a23a8dd02fd5e7e40b18 44 | tftpd/tftp-utils.c freebsd libexec/tftpd/tftp-utils.c 4d09eb87c5d5bec2e2832f50537e2ce6f75f4117 45 | tftpd/tftp-utils.h freebsd libexec/tftpd/tftp-utils.h 4d09eb87c5d5bec2e2832f50537e2ce6f75f4117 46 | tftpd/tftp.plist unknown 47 | tftpd/tftpd.8 freebsd libexec/tftpd/tftpd.8 816c4d3dcf99adcd40a03d93431237ddbd23bbdf 48 | tftpd/tftpd.c freebsd libexec/tftpd/tftpd.c 25945af47e7a1d06c44c8c160045a866e90569ab 49 | tftpd/tests/functional.c freebsd libexec/tftpd/tests/functional.c ae285a8cbf1212bdc1b3f81219635bc1395fadee 50 | 51 | wall/ttymsg.c freebsd usr.bin/wall/ttymsg.c 1a874a126a54fdc188cebd0c58579851c37d1814 52 | wall/ttymsg.h freebsd usr.bin/wall/ttymsg.h 1a874a126a54fdc188cebd0c58579851c37d1814 53 | wall/wall.1 freebsd usr.bin/wall/wall.1 fbbd9655e5107c68e4e0146ff22b73d7350475bc 54 | wall/wall.c freebsd usr.bin/wall/wall.c e8d2bea9cb59ac6c803ce83865bb37c1ac420c60 55 | -------------------------------------------------------------------------------- /tftpd/tftp-utils.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause 3 | * 4 | * Copyright (C) 2008 Edwin Groothuis. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | /* 29 | */ 30 | #define TIMEOUT 5 31 | #define MAX_TIMEOUTS 5 32 | 33 | /* Generic values */ 34 | #define MAXSEGSIZE 65464 /* Maximum size of the data segment */ 35 | #define MAXPKTSIZE (MAXSEGSIZE + 4) /* Maximum size of the packet */ 36 | 37 | /* For the blksize option */ 38 | #define BLKSIZE_MIN 8 /* Minimum size of the data segment */ 39 | #define BLKSIZE_MAX MAXSEGSIZE /* Maximum size of the data segment */ 40 | 41 | /* For the timeout option */ 42 | #define TIMEOUT_MIN 0 /* Minimum timeout value */ 43 | #define TIMEOUT_MAX 255 /* Maximum timeout value */ 44 | #define MIN_TIMEOUTS 3 45 | 46 | /* For the windowsize option */ 47 | #define WINDOWSIZE 1 48 | #define WINDOWSIZE_MIN 1 49 | #define WINDOWSIZE_MAX 65535 50 | 51 | extern int timeoutpacket; 52 | extern int timeoutnetwork; 53 | extern int maxtimeouts; 54 | int settimeouts(int timeoutpacket, int timeoutnetwork, int maxtimeouts); 55 | 56 | extern uint16_t segsize; 57 | extern uint16_t pktsize; 58 | extern uint16_t windowsize; 59 | 60 | extern int acting_as_client; 61 | 62 | /* 63 | */ 64 | void unmappedaddr(struct sockaddr_in6 *sin6); 65 | size_t get_field(int peer, char *buffer, size_t size); 66 | 67 | /* 68 | * Packet types 69 | */ 70 | struct packettypes { 71 | int value; 72 | const char *const name; 73 | }; 74 | extern struct packettypes packettypes[]; 75 | const char *packettype(int); 76 | 77 | /* 78 | * RP_ 79 | */ 80 | struct rp_errors { 81 | int error; 82 | const char *const desc; 83 | }; 84 | extern struct rp_errors rp_errors[]; 85 | char *rp_strerror(int error); 86 | 87 | /* 88 | * Debug features 89 | */ 90 | #define DEBUG_NONE 0x0000 91 | #define DEBUG_PACKETS 0x0001 92 | #define DEBUG_SIMPLE 0x0002 93 | #define DEBUG_OPTIONS 0x0004 94 | #define DEBUG_ACCESS 0x0008 95 | struct debugs { 96 | int value; 97 | const char *const name; 98 | const char *const desc; 99 | }; 100 | extern int debug; 101 | extern struct debugs debugs[]; 102 | extern unsigned int packetdroppercentage; 103 | int debug_find(char *s); 104 | int debug_finds(char *s); 105 | const char *debug_show(int d); 106 | 107 | /* 108 | * Log routines 109 | */ 110 | #define DEBUG(s) tftp_log(LOG_DEBUG, "%s", s) 111 | extern int tftp_logtostdout; 112 | void tftp_openlog(const char *ident, int logopt, int facility); 113 | void tftp_closelog(void); 114 | void tftp_log(int priority, const char *message, ...) __printflike(2, 3); 115 | 116 | /* 117 | * Performance figures 118 | */ 119 | struct tftp_stats { 120 | size_t amount; 121 | int rollovers; 122 | uint32_t blocks; 123 | int retries; 124 | struct timeval tstart; 125 | struct timeval tstop; 126 | }; 127 | 128 | void stats_init(struct tftp_stats *ts); 129 | void printstats(const char *direction, int verbose, struct tftp_stats *ts); 130 | -------------------------------------------------------------------------------- /talk/look_up.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | #ifndef __APPLE__ 35 | __FBSDID("$FreeBSD$"); 36 | 37 | #ifndef lint 38 | static const char sccsid[] = "@(#)look_up.c 8.1 (Berkeley) 6/6/93"; 39 | #endif 40 | #endif /* __APPLE__ */ 41 | 42 | #include 43 | #include 44 | #include 45 | 46 | #include 47 | #include 48 | #include 49 | 50 | #include "talk_ctl.h" 51 | #include "talk.h" 52 | 53 | /* 54 | * See if the local daemon has an invitation for us. 55 | */ 56 | int 57 | check_local(void) 58 | { 59 | CTL_RESPONSE response; 60 | CTL_RESPONSE *rp = &response; 61 | struct sockaddr addr; 62 | 63 | /* the rest of msg was set up in get_names */ 64 | /* copy new style sockaddr to old, swap family (short in old) */ 65 | msg.ctl_addr = *(struct tsockaddr *)&ctl_addr; 66 | msg.ctl_addr.sa_family = htons(ctl_addr.sin_family); 67 | /* must be initiating a talk */ 68 | if (!look_for_invite(rp)) 69 | return (0); 70 | /* 71 | * There was an invitation waiting for us, 72 | * so connect with the other (hopefully waiting) party 73 | */ 74 | current_state = "Waiting to connect with caller"; 75 | do { 76 | if (rp->addr.sa_family != AF_INET) 77 | p_error("Response uses invalid network address"); 78 | (void)memcpy(&addr, &rp->addr.sa_family, sizeof(addr)); 79 | addr.sa_family = rp->addr.sa_family; 80 | addr.sa_len = sizeof(addr); 81 | errno = 0; 82 | if (connect(sockt, &addr, sizeof(addr)) != -1) 83 | return (1); 84 | } while (errno == EINTR); 85 | if (errno == ECONNREFUSED) { 86 | /* 87 | * The caller gave up, but his invitation somehow 88 | * was not cleared. Clear it and initiate an 89 | * invitation. (We know there are no newer invitations, 90 | * the talkd works LIFO.) 91 | */ 92 | ctl_transact(his_machine_addr, msg, DELETE, rp); 93 | close(sockt); 94 | open_sockt(); 95 | return (0); 96 | } 97 | p_error("Unable to connect with initiator"); 98 | /*NOTREACHED*/ 99 | return (0); 100 | } 101 | 102 | /* 103 | * Look for an invitation on 'machine' 104 | */ 105 | int 106 | look_for_invite(CTL_RESPONSE *rp) 107 | { 108 | current_state = "Checking for invitation on caller's machine"; 109 | ctl_transact(his_machine_addr, msg, LOOK_UP, rp); 110 | /* the switch is for later options, such as multiple invitations */ 111 | switch (rp->answer) { 112 | 113 | case SUCCESS: 114 | msg.id_num = htonl(rp->id_num); 115 | return (1); 116 | 117 | default: 118 | /* there wasn't an invitation waiting for us */ 119 | return (0); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /talk/ctl.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | #ifndef __APPLE__ 35 | __FBSDID("$FreeBSD$"); 36 | 37 | #ifndef lint 38 | static const char sccsid[] = "@(#)ctl.c 8.1 (Berkeley) 6/6/93"; 39 | #endif 40 | #endif /* __APPLE__ */ 41 | 42 | /* 43 | * This file handles haggling with the various talk daemons to 44 | * get a socket to talk to. sockt is opened and connected in 45 | * the progress 46 | */ 47 | 48 | #include 49 | #include 50 | 51 | #include 52 | 53 | #include "talk.h" 54 | #include "talk_ctl.h" 55 | 56 | struct sockaddr_in daemon_addr = { .sin_len = sizeof(daemon_addr), .sin_family = AF_INET }; 57 | struct sockaddr_in ctl_addr = { .sin_len = sizeof(ctl_addr), .sin_family = AF_INET }; 58 | struct sockaddr_in my_addr = { .sin_len = sizeof(my_addr), .sin_family = AF_INET }; 59 | 60 | /* inet addresses of the two machines */ 61 | struct in_addr my_machine_addr; 62 | struct in_addr his_machine_addr; 63 | 64 | u_short daemon_port; /* port number of the talk daemon */ 65 | 66 | int ctl_sockt; 67 | int sockt; 68 | int invitation_waiting = 0; 69 | 70 | CTL_MSG msg; 71 | 72 | void 73 | open_sockt(void) 74 | { 75 | socklen_t length; 76 | 77 | (void)memset(&my_addr, 0, sizeof(my_addr)); 78 | my_addr.sin_family = AF_INET; 79 | my_addr.sin_len = sizeof(my_addr); 80 | my_addr.sin_addr = my_machine_addr; 81 | my_addr.sin_port = 0; 82 | sockt = socket(AF_INET, SOCK_STREAM, 0); 83 | if (sockt == -1) 84 | p_error("Bad socket"); 85 | if (bind(sockt, (struct sockaddr *)&my_addr, sizeof(my_addr)) != 0) 86 | p_error("Binding local socket"); 87 | length = sizeof(my_addr); 88 | if (getsockname(sockt, (struct sockaddr *)&my_addr, &length) == -1) 89 | p_error("Bad address for socket"); 90 | } 91 | 92 | /* open the ctl socket */ 93 | void 94 | open_ctl(void) 95 | { 96 | socklen_t length; 97 | 98 | (void)memset(&ctl_addr, 0, sizeof(ctl_addr)); 99 | ctl_addr.sin_family = AF_INET; 100 | ctl_addr.sin_len = sizeof(my_addr); 101 | ctl_addr.sin_port = 0; 102 | ctl_addr.sin_addr = my_machine_addr; 103 | ctl_sockt = socket(AF_INET, SOCK_DGRAM, 0); 104 | if (ctl_sockt == -1) 105 | p_error("Bad socket"); 106 | if (bind(ctl_sockt, 107 | (struct sockaddr *)&ctl_addr, sizeof(ctl_addr)) != 0) 108 | p_error("Couldn't bind to control socket"); 109 | length = sizeof(ctl_addr); 110 | if (getsockname(ctl_sockt, 111 | (struct sockaddr *)&ctl_addr, &length) == -1) 112 | p_error("Bad address for ctl socket"); 113 | } 114 | 115 | /* print_addr is a debug print routine */ 116 | void 117 | print_addr(struct sockaddr_in addr) 118 | { 119 | int i; 120 | 121 | printf("addr = %lx, port = %o, family = %o zero = ", 122 | (u_long)addr.sin_addr.s_addr, addr.sin_port, addr.sin_family); 123 | for (i = 0; i<8;i++) 124 | printf("%o ", (int)addr.sin_zero[i]); 125 | putchar('\n'); 126 | } 127 | -------------------------------------------------------------------------------- /talkd/talkd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | __attribute__((__used__)) 34 | static const char copyright[] = 35 | "@(#) Copyright (c) 1983, 1993\n\ 36 | The Regents of the University of California. All rights reserved.\n"; 37 | #endif /* not lint */ 38 | 39 | #ifndef lint 40 | #if 0 41 | static char sccsid[] = "@(#)talkd.c 8.1 (Berkeley) 6/4/93"; 42 | #endif 43 | __attribute__((__used__)) 44 | static const char rcsid[] = 45 | "$FreeBSD$"; 46 | #endif /* not lint */ 47 | 48 | /* 49 | * The top level of the daemon, the format is heavily borrowed 50 | * from rwhod.c. Basically: find out who and where you are; 51 | * disconnect all descriptors and ttys, and then endless 52 | * loop on waiting for and processing requests 53 | */ 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | #include 68 | #include 69 | 70 | #include "extern.h" 71 | 72 | static CTL_MSG request; 73 | static CTL_RESPONSE response; 74 | 75 | int debug = 0; 76 | static long lastmsgtime; 77 | 78 | char hostname[MAXHOSTNAMELEN]; 79 | 80 | #define TIMEOUT 30 81 | #define MAXIDLE 120 82 | 83 | int 84 | main(int argc, char *argv[]) 85 | { 86 | register CTL_MSG *mp = &request; 87 | int cc; 88 | struct sockaddr ctl_addr; 89 | 90 | #ifdef NOTDEF 91 | /* 92 | * removed so ntalkd can run in tty sandbox 93 | */ 94 | if (getuid()) 95 | errx(1, "getuid: not super-user"); 96 | #endif 97 | openlog("talkd", LOG_PID, LOG_DAEMON); 98 | if (gethostname(hostname, sizeof(hostname) - 1) < 0) { 99 | syslog(LOG_ERR, "gethostname: %m"); 100 | _exit(1); 101 | } 102 | hostname[sizeof(hostname) - 1] = '\0'; 103 | if (chdir(_PATH_DEV) < 0) { 104 | syslog(LOG_ERR, "chdir: %s: %m", _PATH_DEV); 105 | _exit(1); 106 | } 107 | if (argc > 1 && strcmp(argv[1], "-d") == 0) 108 | debug = 1; 109 | signal(SIGALRM, timeout); 110 | alarm(TIMEOUT); 111 | for (;;) { 112 | cc = recv(0, (char *)mp, sizeof(*mp), 0); 113 | if (cc != sizeof (*mp)) { 114 | if (cc < 0 && errno != EINTR) 115 | syslog(LOG_WARNING, "recv: %m"); 116 | continue; 117 | } 118 | lastmsgtime = time(0); 119 | (void)memcpy(&ctl_addr.sa_data, &mp->ctl_addr.sa_data, 120 | sizeof(ctl_addr.sa_data)); 121 | ctl_addr.sa_family = ntohs(mp->ctl_addr.sa_family); 122 | ctl_addr.sa_len = sizeof(ctl_addr); 123 | process_request(mp, &response); 124 | /* can block here, is this what I want? */ 125 | cc = sendto(STDIN_FILENO, (char *)&response, 126 | sizeof(response), 0, &ctl_addr, sizeof(ctl_addr)); 127 | if (cc != sizeof (response)) 128 | syslog(LOG_WARNING, "sendto: %m"); 129 | } 130 | } 131 | 132 | void 133 | timeout(int sig __unused) 134 | { 135 | int save_errno = errno; 136 | 137 | if (time(0) - lastmsgtime >= MAXIDLE) 138 | _exit(0); 139 | alarm(TIMEOUT); 140 | errno = save_errno; 141 | } 142 | -------------------------------------------------------------------------------- /talk/talk.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1983, 1990, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions 6 | .\" are met: 7 | .\" 1. Redistributions of source code must retain the above copyright 8 | .\" notice, this list of conditions and the following disclaimer. 9 | .\" 2. Redistributions in binary form must reproduce the above copyright 10 | .\" notice, this list of conditions and the following disclaimer in the 11 | .\" documentation and/or other materials provided with the distribution. 12 | .\" 3. Neither the name of the University nor the names of its contributors 13 | .\" may be used to endorse or promote products derived from this software 14 | .\" without specific prior written permission. 15 | .\" 16 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | .\" SUCH DAMAGE. 27 | .\" 28 | .\" @(#)talk.1 8.1 (Berkeley) 6/6/93 29 | .\" $FreeBSD$ 30 | .\" 31 | .Dd January 21, 2010 32 | .Dt TALK 1 33 | .Os 34 | .Sh NAME 35 | .Nm talk 36 | .Nd talk to another user 37 | .Sh SYNOPSIS 38 | .Nm 39 | .Ar person 40 | .Op Ar ttyname 41 | .Sh DESCRIPTION 42 | The 43 | .Nm 44 | utility is a visual communication program which copies lines from your 45 | terminal to that of another user. 46 | .Pp 47 | Options available: 48 | .Bl -tag -width ttyname 49 | .It Ar person 50 | If you wish to talk to someone on your own machine, then 51 | .Ar person 52 | is just the person's login name. 53 | If you wish to talk to a user on 54 | another host, then 55 | .Ar person 56 | is of the form 57 | .Ql user@host 58 | or 59 | .Ql host!user 60 | or 61 | .Ql host:user . 62 | .It Ar ttyname 63 | If you wish to talk to a user who is logged in more than once, the 64 | .Ar ttyname 65 | argument may be used to indicate the appropriate terminal 66 | name, where 67 | .Ar ttyname 68 | is of the form 69 | .Ql ttyXX . 70 | .El 71 | .Pp 72 | When first called, 73 | .Nm 74 | sends the message 75 | .Bd -literal -offset indent -compact 76 | Message from TalkDaemon@his_machine... 77 | talk: connection requested by your_name@your_machine. 78 | talk: respond with: talk your_name@your_machine 79 | .Ed 80 | .Pp 81 | to the user you wish to talk to. 82 | At this point, the recipient 83 | of the message should reply by typing 84 | .Pp 85 | .Dl talk \ your_name@your_machine 86 | .Pp 87 | It does not matter from which machine the recipient replies, as 88 | long as his login-name is the same. 89 | Once communication is established, 90 | the two parties may type simultaneously, with their output appearing 91 | in separate windows. 92 | Typing control-L 93 | .Ql ^L 94 | will cause the screen to 95 | be reprinted. 96 | Typing control-D 97 | .Ql ^D 98 | will clear both parts of your screen to be cleared, while 99 | the control-D character will be sent to the remote side 100 | (and just displayed by this 101 | .Nm 102 | client). 103 | Your erase, kill, and word kill characters will 104 | behave normally. 105 | To exit, just type your interrupt character; 106 | .Nm 107 | then moves the cursor to the bottom of the screen and restores the 108 | terminal to its previous state. 109 | .Pp 110 | Permission to talk may be denied or granted by use of the 111 | .Xr mesg 1 112 | command. 113 | At the outset talking is allowed. 114 | .Sh CONFIGURATION 115 | The 116 | .Nm 117 | utility relies on the 118 | .Nm talkd 119 | system daemon. See 120 | .Xr talkd 8 121 | for information about enabling 122 | .Nm talkd . 123 | .Sh FILES 124 | .Bl -tag -width /var/run/utmpx -compact 125 | .It Pa /etc/hosts 126 | to find the recipient's machine 127 | .It Pa /var/run/utmpx 128 | to find the recipient's tty 129 | .El 130 | .Sh SEE ALSO 131 | .Xr mail 1 , 132 | .Xr mesg 1 , 133 | .Xr wall 1 , 134 | .Xr who 1 , 135 | .Xr write 1 , 136 | .Xr talkd 8 137 | .Sh HISTORY 138 | The 139 | .Nm 140 | command appeared in 141 | .Bx 4.2 . 142 | .Pp 143 | In 144 | .Fx 5.3 , 145 | the default behaviour of 146 | .Nm 147 | was changed to treat local-to-local talk requests as originating 148 | and terminating at 149 | .Em localhost . 150 | Before this change, it was required that the hostname (as per 151 | .Xr gethostname 3 ) 152 | resolved to a valid IPv4 address (via 153 | .Xr gethostbyname 3 ) , 154 | making 155 | .Nm 156 | unsuitable for use in configurations where 157 | .Xr talkd 8 158 | was bound to the loopback interface (normally for security reasons). 159 | .Sh BUGS 160 | The version of 161 | .Nm 162 | released with 163 | .Bx 4.3 164 | uses a protocol that 165 | is incompatible with the protocol used in the version released with 166 | .Bx 4.2 . 167 | .Pp 168 | Multibyte characters are not recognized. 169 | -------------------------------------------------------------------------------- /telnet/network.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1988, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | 34 | #if 0 35 | #ifndef lint 36 | static const char sccsid[] = "@(#)network.c 8.2 (Berkeley) 12/15/93"; 37 | #endif 38 | #endif 39 | #include 40 | __FBSDID("$FreeBSD: src/contrib/telnet/telnet/network.c,v 1.7 2003/05/04 02:54:48 obrien Exp $"); 41 | 42 | #include 43 | #include 44 | #include 45 | 46 | #include 47 | #include 48 | 49 | #include 50 | #include 51 | 52 | #include "ring.h" 53 | 54 | #include "defines.h" 55 | #include "externs.h" 56 | #include "fdset.h" 57 | 58 | Ring netoring, netiring; 59 | unsigned char netobuf[2*BUFSIZ], netibuf[BUFSIZ]; 60 | 61 | /* 62 | * Initialize internal network data structures. 63 | */ 64 | 65 | void 66 | init_network(void) 67 | { 68 | if (ring_init(&netoring, netobuf, sizeof netobuf) != 1) { 69 | exit(1); 70 | } 71 | if (ring_init(&netiring, netibuf, sizeof netibuf) != 1) { 72 | exit(1); 73 | } 74 | NetTrace = stdout; 75 | } 76 | 77 | 78 | /* 79 | * Check to see if any out-of-band data exists on a socket (for 80 | * Telnet "synch" processing). 81 | */ 82 | 83 | int 84 | stilloob(void) 85 | { 86 | static struct timeval timeout = { 0, 0 }; 87 | fd_set excepts; 88 | int value; 89 | 90 | do { 91 | FD_ZERO(&excepts); 92 | FD_SET(net, &excepts); 93 | value = select(net+1, (fd_set *)0, (fd_set *)0, &excepts, &timeout); 94 | } while ((value == -1) && (errno == EINTR)); 95 | 96 | if (value < 0) { 97 | perror("select"); 98 | (void) quit(); 99 | /* NOTREACHED */ 100 | } 101 | if (FD_ISSET(net, &excepts)) { 102 | return 1; 103 | } else { 104 | return 0; 105 | } 106 | } 107 | 108 | 109 | /* 110 | * setneturg() 111 | * 112 | * Sets "neturg" to the current location. 113 | */ 114 | 115 | void 116 | setneturg(void) 117 | { 118 | ring_mark(&netoring); 119 | } 120 | 121 | 122 | /* 123 | * netflush 124 | * Send as much data as possible to the network, 125 | * handling requests for urgent data. 126 | * 127 | * The return value indicates whether we did any 128 | * useful work. 129 | */ 130 | 131 | int 132 | netflush(void) 133 | { 134 | int n, n1; 135 | 136 | #ifdef ENCRYPTION 137 | if (encrypt_output) 138 | ring_encrypt(&netoring, encrypt_output); 139 | #endif /* ENCRYPTION */ 140 | if ((n1 = n = ring_full_consecutive(&netoring)) > 0) { 141 | if (!ring_at_mark(&netoring)) { 142 | n = send(net, (char *)netoring.consume, n, 0); /* normal write */ 143 | } else { 144 | /* 145 | * In 4.2 (and 4.3) systems, there is some question about 146 | * what byte in a sendOOB operation is the "OOB" data. 147 | * To make ourselves compatible, we only send ONE byte 148 | * out of band, the one WE THINK should be OOB (though 149 | * we really have more the TCP philosophy of urgent data 150 | * rather than the Unix philosophy of OOB data). 151 | */ 152 | n = send(net, (char *)netoring.consume, 1, MSG_OOB);/* URGENT data */ 153 | } 154 | } 155 | if (n < 0) { 156 | if (errno != ENOBUFS && errno != EWOULDBLOCK) { 157 | setcommandmode(); 158 | perror(hostname); 159 | (void)NetClose(net); 160 | ring_clear_mark(&netoring); 161 | longjmp(peerdied, -1); 162 | /*NOTREACHED*/ 163 | } 164 | n = 0; 165 | } 166 | if (netdata && n) { 167 | Dump('>', netoring.consume, n); 168 | } 169 | if (n) { 170 | ring_consumed(&netoring, n); 171 | /* 172 | * If we sent all, and more to send, then recurse to pick 173 | * up the other half. 174 | */ 175 | if ((n1 == n) && ring_full_consecutive(&netoring)) { 176 | (void) netflush(); 177 | } 178 | return 1; 179 | } else { 180 | return 0; 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /wall/ttymsg.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1989, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | __FBSDID("$FreeBSD$"); 35 | 36 | #ifndef lint 37 | __attribute__((__used__)) 38 | static const char sccsid[] = "@(#)ttymsg.c 8.2 (Berkeley) 11/16/93"; 39 | #endif 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | 53 | #include "ttymsg.h" 54 | 55 | /* 56 | * Display the contents of a uio structure on a terminal. Used by wall(1), 57 | * syslogd(8), and talkd(8). Forks and finishes in child if write would block, 58 | * waiting up to tmout seconds. Returns pointer to error string on unexpected 59 | * error; string is not newline-terminated. Various "normal" errors are 60 | * ignored (exclusive-use, lack of permission, etc.). 61 | */ 62 | const char * 63 | ttymsg(struct iovec *iov, int iovcnt, const char *line, int tmout) 64 | { 65 | struct iovec localiov[TTYMSG_IOV_MAX]; 66 | ssize_t left, wret; 67 | int cnt, fd; 68 | char device[MAXNAMLEN] = _PATH_DEV; 69 | static char errbuf[1024]; 70 | char *p; 71 | int forked; 72 | 73 | forked = 0; 74 | if (iovcnt > (int)(sizeof(localiov) / sizeof(localiov[0]))) 75 | return ("too many iov's (change code in wall/ttymsg.c)"); 76 | 77 | strlcat(device, line, sizeof(device)); 78 | p = device + sizeof(_PATH_DEV) - 1; 79 | if (strncmp(p, "pts/", 4) == 0) 80 | p += 4; 81 | if (strchr(p, '/') != NULL) { 82 | /* A slash is an attempt to break security... */ 83 | (void) snprintf(errbuf, sizeof(errbuf), 84 | "Too many '/' in \"%s\"", device); 85 | return (errbuf); 86 | } 87 | 88 | /* 89 | * open will fail on slip lines or exclusive-use lines 90 | * if not running as root; not an error. 91 | */ 92 | if ((fd = open(device, O_WRONLY|O_NONBLOCK, 0)) < 0) { 93 | #ifndef __APPLE__ 94 | if (errno == EBUSY || errno == EACCES) 95 | return (NULL); 96 | #endif /* !__APPLE__ */ 97 | (void) snprintf(errbuf, sizeof(errbuf), "%s: %s", device, 98 | strerror(errno)); 99 | return (errbuf); 100 | } 101 | 102 | for (cnt = 0, left = 0; cnt < iovcnt; ++cnt) 103 | left += iov[cnt].iov_len; 104 | 105 | for (;;) { 106 | wret = writev(fd, iov, iovcnt); 107 | if (wret >= left) 108 | break; 109 | if (wret >= 0) { 110 | left -= wret; 111 | if (iov != localiov) { 112 | bcopy(iov, localiov, 113 | iovcnt * sizeof(struct iovec)); 114 | iov = localiov; 115 | } 116 | for (cnt = 0; (size_t)wret >= iov->iov_len; ++cnt) { 117 | wret -= iov->iov_len; 118 | ++iov; 119 | --iovcnt; 120 | } 121 | if (wret) { 122 | iov->iov_base = (char *)iov->iov_base + wret; 123 | iov->iov_len -= wret; 124 | } 125 | continue; 126 | } 127 | if (errno == EWOULDBLOCK) { 128 | int cpid; 129 | 130 | if (forked) { 131 | (void) close(fd); 132 | _exit(1); 133 | } 134 | cpid = fork(); 135 | if (cpid < 0) { 136 | (void) snprintf(errbuf, sizeof(errbuf), 137 | "fork: %s", strerror(errno)); 138 | (void) close(fd); 139 | return (errbuf); 140 | } 141 | if (cpid) { /* parent */ 142 | (void) close(fd); 143 | return (NULL); 144 | } 145 | forked++; 146 | /* wait at most tmout seconds */ 147 | (void) signal(SIGALRM, SIG_DFL); 148 | (void) signal(SIGTERM, SIG_DFL); /* XXX */ 149 | (void) sigsetmask(0); 150 | (void) alarm((u_int)tmout); 151 | (void) fcntl(fd, F_SETFL, 0); /* clear O_NONBLOCK */ 152 | continue; 153 | } 154 | /* 155 | * We get ENODEV on a slip line if we're running as root, 156 | * and EIO if the line just went away. 157 | */ 158 | if (errno == ENODEV || errno == EIO) 159 | break; 160 | (void) close(fd); 161 | if (forked) 162 | _exit(1); 163 | (void) snprintf(errbuf, sizeof(errbuf), 164 | "%s: %s", device, strerror(errno)); 165 | return (errbuf); 166 | } 167 | 168 | (void) close(fd); 169 | if (forked) 170 | _exit(0); 171 | return (NULL); 172 | } 173 | -------------------------------------------------------------------------------- /talk/io.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | #ifndef __APPLE__ 35 | __FBSDID("$FreeBSD$"); 36 | 37 | #ifndef lint 38 | static const char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93"; 39 | #endif 40 | #endif /* __APPLE__ */ 41 | 42 | /* 43 | * This file contains the I/O handling and the exchange of 44 | * edit characters. This connection itself is established in 45 | * ctl.c 46 | */ 47 | 48 | #include 49 | 50 | #include 51 | #include 52 | #include 53 | #include 54 | #ifdef __APPLE__ 55 | #define INFTIM -1 56 | #endif /* __APPLE__ */ 57 | #include 58 | #include 59 | #include 60 | #include 61 | #define _XOPEN_SOURCE_EXTENDED 62 | #include 63 | 64 | #include "talk.h" 65 | #include "talk_ctl.h" 66 | 67 | extern void display(xwin_t *, wchar_t *); 68 | 69 | volatile sig_atomic_t gotwinch = 0; 70 | 71 | /* 72 | * The routine to do the actual talking 73 | */ 74 | void 75 | talk(void) 76 | { 77 | struct hostent *hp, *hp2; 78 | struct pollfd fds[2]; 79 | int nb; 80 | wchar_t buf[BUFSIZ]; 81 | char **addr, *his_machine_name; 82 | FILE *sockfp; 83 | 84 | his_machine_name = NULL; 85 | hp = gethostbyaddr((const char *)&his_machine_addr.s_addr, 86 | sizeof(his_machine_addr.s_addr), AF_INET); 87 | if (hp != NULL) { 88 | hp2 = gethostbyname(hp->h_name); 89 | if (hp2 != NULL && hp2->h_addrtype == AF_INET && 90 | hp2->h_length == sizeof(his_machine_addr)) 91 | for (addr = hp2->h_addr_list; *addr != NULL; addr++) 92 | if (memcmp(*addr, &his_machine_addr, 93 | sizeof(his_machine_addr)) == 0) { 94 | his_machine_name = strdup(hp->h_name); 95 | break; 96 | } 97 | } 98 | if (his_machine_name == NULL) 99 | his_machine_name = strdup(inet_ntoa(his_machine_addr)); 100 | snprintf((char *)buf, sizeof(buf), "Connection established with %s@%s.", 101 | msg.r_name, his_machine_name); 102 | free(his_machine_name); 103 | message((char *)buf); 104 | write(STDOUT_FILENO, "\007\007\007", 3); 105 | 106 | current_line = 0; 107 | 108 | if ((sockfp = fdopen(sockt, "w+")) == NULL) 109 | p_error("fdopen"); 110 | 111 | setvbuf(sockfp, NULL, _IONBF, 0); 112 | setvbuf(stdin, NULL, _IONBF, 0); 113 | 114 | /* 115 | * Wait on both the other process (sockt) and standard input. 116 | */ 117 | for (;;) { 118 | fds[0].fd = fileno(stdin); 119 | fds[0].events = POLLIN; 120 | fds[1].fd = sockt; 121 | fds[1].events = POLLIN; 122 | nb = poll(fds, 2, INFTIM); 123 | if (gotwinch) { 124 | resize_display(); 125 | gotwinch = 0; 126 | } 127 | if (nb <= 0) { 128 | if (errno == EINTR) 129 | continue; 130 | /* Panic, we don't know what happened. */ 131 | p_error("Unexpected error from poll"); 132 | quit(); 133 | } 134 | if (fds[1].revents & POLLIN) { 135 | wint_t w; 136 | 137 | /* There is data on sockt. */ 138 | w = fgetwc(sockfp); 139 | if (w == WEOF) { 140 | message("Connection closed. Exiting"); 141 | quit(); 142 | } 143 | display(&his_win, &w); 144 | } 145 | if (fds[0].revents & POLLIN) { 146 | wint_t w; 147 | 148 | if ((w = getwchar()) != WEOF) { 149 | display(&my_win, &w); 150 | (void )fputwc(w, sockfp); 151 | (void )fflush(sockfp); 152 | } 153 | } 154 | } 155 | } 156 | 157 | /* 158 | * p_error prints the system error message on the standard location 159 | * on the screen and then exits. (i.e. a curses version of perror) 160 | */ 161 | void 162 | p_error(const char *string) 163 | { 164 | wmove(my_win.x_win, current_line, 0); 165 | wprintw(my_win.x_win, "[%s : %s (%d)]\n", 166 | string, strerror(errno), errno); 167 | wrefresh(my_win.x_win); 168 | move(LINES-1, 0); 169 | refresh(); 170 | quit(); 171 | } 172 | 173 | /* 174 | * Display string in the standard location 175 | */ 176 | void 177 | message(const char *string) 178 | { 179 | wmove(my_win.x_win, current_line, 0); 180 | wprintw(my_win.x_win, "[%s]\n", string); 181 | if (current_line < my_win.x_nlines - 1) 182 | current_line++; 183 | wrefresh(my_win.x_win); 184 | } 185 | -------------------------------------------------------------------------------- /talkd/announce.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | #if 0 34 | static char sccsid[] = "@(#)announce.c 8.3 (Berkeley) 4/28/95"; 35 | #endif 36 | __attribute__((__used__)) 37 | static const char rcsid[] = 38 | "$FreeBSD$"; 39 | #endif /* not lint */ 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include 49 | 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | 59 | #ifdef __APPLE__ 60 | #include 61 | #else 62 | #include "ttymsg.h" 63 | #endif 64 | #include "extern.h" 65 | 66 | /* 67 | * Announce an invitation to talk. 68 | */ 69 | 70 | /* 71 | * See if the user is accepting messages. If so, announce that 72 | * a talk is requested. 73 | */ 74 | int 75 | announce(CTL_MSG *request, const char *remote_machine) 76 | { 77 | char full_tty[32]; 78 | struct stat stbuf; 79 | 80 | (void)snprintf(full_tty, sizeof(full_tty), 81 | "%s%s", _PATH_DEV, request->r_tty); 82 | if (stat(full_tty, &stbuf) < 0 || (stbuf.st_mode&020) == 0) 83 | return (PERMISSION_DENIED); 84 | return (print_mesg(request->r_tty, request, remote_machine)); 85 | } 86 | 87 | #define max(a,b) ( (a) > (b) ? (a) : (b) ) 88 | #define N_LINES 5 89 | #define N_CHARS 256 90 | 91 | /* 92 | * Build a block of characters containing the message. 93 | * It is sent blank filled and in a single block to 94 | * try to keep the message in one piece if the recipient 95 | * in vi at the time 96 | */ 97 | int 98 | print_mesg(const char *tty, CTL_MSG *request, 99 | const char *remote_machine) 100 | { 101 | struct timeval now; 102 | time_t clock_sec; 103 | struct tm *localclock; 104 | struct iovec iovec; 105 | char line_buf[N_LINES][N_CHARS]; 106 | int sizes[N_LINES]; 107 | char big_buf[N_LINES*N_CHARS]; 108 | char *bptr, *lptr, *vis_user; 109 | int i, j, max_size; 110 | 111 | i = 0; 112 | max_size = 0; 113 | gettimeofday(&now, NULL); 114 | clock_sec = now.tv_sec; 115 | localclock = localtime(&clock_sec); 116 | (void)snprintf(line_buf[i], N_CHARS, " "); 117 | sizes[i] = strlen(line_buf[i]); 118 | max_size = max(max_size, sizes[i]); 119 | i++; 120 | (void)snprintf(line_buf[i], N_CHARS, 121 | "Message from Talk_Daemon@%s at %d:%02d on %d/%.2d/%.2d ...", 122 | hostname, localclock->tm_hour , localclock->tm_min, 123 | localclock->tm_year + 1900, localclock->tm_mon + 1, 124 | localclock->tm_mday); 125 | sizes[i] = strlen(line_buf[i]); 126 | max_size = max(max_size, sizes[i]); 127 | i++; 128 | 129 | vis_user = malloc(strlen(request->l_name) * 4 + 1); 130 | strvis(vis_user, request->l_name, VIS_CSTYLE); 131 | (void)snprintf(line_buf[i], N_CHARS, 132 | "talk: connection requested by %s@%s", vis_user, remote_machine); 133 | sizes[i] = strlen(line_buf[i]); 134 | max_size = max(max_size, sizes[i]); 135 | i++; 136 | (void)snprintf(line_buf[i], N_CHARS, "talk: respond with: talk %s@%s", 137 | vis_user, remote_machine); 138 | sizes[i] = strlen(line_buf[i]); 139 | max_size = max(max_size, sizes[i]); 140 | i++; 141 | (void)snprintf(line_buf[i], N_CHARS, " "); 142 | sizes[i] = strlen(line_buf[i]); 143 | max_size = max(max_size, sizes[i]); 144 | i++; 145 | bptr = big_buf; 146 | *bptr++ = '\007'; /* send something to wake them up */ 147 | *bptr++ = '\r'; /* add a \r in case of raw mode */ 148 | *bptr++ = '\n'; 149 | for (i = 0; i < N_LINES; i++) { 150 | /* copy the line into the big buffer */ 151 | lptr = line_buf[i]; 152 | while (*lptr != '\0') 153 | *(bptr++) = *(lptr++); 154 | /* pad out the rest of the lines with blanks */ 155 | for (j = sizes[i]; j < max_size + 2; j++) 156 | *(bptr++) = ' '; 157 | *(bptr++) = '\r'; /* add a \r in case of raw mode */ 158 | *(bptr++) = '\n'; 159 | } 160 | *bptr = '\0'; 161 | iovec.iov_base = big_buf; 162 | iovec.iov_len = bptr - big_buf; 163 | /* 164 | * we choose a timeout of RING_WAIT-5 seconds so that we don't 165 | * stack up processes trying to write messages to a tty 166 | * that is permanently blocked. 167 | */ 168 | if (ttymsg(&iovec, 1, tty, RING_WAIT - 5) != NULL) 169 | return (FAILED); 170 | 171 | return (SUCCESS); 172 | } 173 | -------------------------------------------------------------------------------- /talk/display.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | #ifndef __APPLE__ 35 | __FBSDID("$FreeBSD$"); 36 | 37 | #ifndef lint 38 | static const char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93"; 39 | #endif 40 | #endif /* __APPLE__ */ 41 | 42 | /* 43 | * The window 'manager', initializes curses and handles the actual 44 | * displaying of text 45 | */ 46 | #include 47 | #include 48 | #include 49 | #define _XOPEN_SOURCE_EXTENDED 50 | #include 51 | 52 | #include "talk.h" 53 | 54 | void display(xwin_t *, wchar_t *); 55 | 56 | xwin_t my_win; 57 | xwin_t his_win; 58 | WINDOW *line_win; 59 | 60 | int curses_initialized = 0; 61 | 62 | /* 63 | * max HAS to be a function, it is called with 64 | * an argument of the form --foo at least once. 65 | */ 66 | int 67 | max(int a, int b) 68 | { 69 | 70 | return (a > b ? a : b); 71 | } 72 | 73 | static cchar_t * 74 | makecchar(wchar_t in) 75 | { 76 | static cchar_t cc; 77 | wchar_t wc[2]; 78 | 79 | wc[0] = in; 80 | wc[1] = L'\0'; 81 | 82 | if (setcchar(&cc, wc, A_NORMAL, 0, NULL) != OK) 83 | p_error("settchar(3) failure"); 84 | 85 | return (&cc); 86 | } 87 | 88 | /* 89 | * Display a symbol on somebody's window, processing some control 90 | * characters while we are at it. 91 | */ 92 | void 93 | display(xwin_t *win, wchar_t *wc) 94 | { 95 | 96 | /* 97 | * Alas, can't use variables in C switch statement. 98 | * Workaround these 3 cases with goto. 99 | */ 100 | if (*wc == win->kill) 101 | goto kill; 102 | else if (*wc == win->cerase) 103 | goto cerase; 104 | else if (*wc == win->werase) 105 | goto werase; 106 | 107 | switch (*wc) { 108 | case L'\n': 109 | case L'\r': 110 | wadd_wch(win->x_win, makecchar(L'\n')); 111 | getyx(win->x_win, win->x_line, win->x_col); 112 | wrefresh(win->x_win); 113 | return; 114 | 115 | case 004: 116 | if (win == &my_win) { 117 | /* Ctrl-D clears the screen. */ 118 | werase(my_win.x_win); 119 | getyx(my_win.x_win, my_win.x_line, my_win.x_col); 120 | wrefresh(my_win.x_win); 121 | werase(his_win.x_win); 122 | getyx(his_win.x_win, his_win.x_line, his_win.x_col); 123 | wrefresh(his_win.x_win); 124 | } 125 | return; 126 | 127 | /* Erase character. */ 128 | case 010: /* BS */ 129 | case 0177: /* DEL */ 130 | cerase: 131 | wmove(win->x_win, win->x_line, max(--win->x_col, 0)); 132 | getyx(win->x_win, win->x_line, win->x_col); 133 | waddch(win->x_win, ' '); 134 | wmove(win->x_win, win->x_line, win->x_col); 135 | getyx(win->x_win, win->x_line, win->x_col); 136 | wrefresh(win->x_win); 137 | return; 138 | 139 | case 027: /* ^W */ 140 | werase: 141 | { 142 | /* 143 | * On word erase search backwards until we find 144 | * the beginning of a word or the beginning of 145 | * the line. 146 | */ 147 | int endcol, xcol, c; 148 | 149 | endcol = win->x_col; 150 | xcol = endcol - 1; 151 | while (xcol >= 0) { 152 | c = readwin(win->x_win, win->x_line, xcol); 153 | if (c != ' ') 154 | break; 155 | xcol--; 156 | } 157 | while (xcol >= 0) { 158 | c = readwin(win->x_win, win->x_line, xcol); 159 | if (c == ' ') 160 | break; 161 | xcol--; 162 | } 163 | wmove(win->x_win, win->x_line, xcol + 1); 164 | for (int i = xcol + 1; i < endcol; i++) 165 | waddch(win->x_win, ' '); 166 | wmove(win->x_win, win->x_line, xcol + 1); 167 | getyx(win->x_win, win->x_line, win->x_col); 168 | wrefresh(win->x_win); 169 | return; 170 | } 171 | 172 | case 025: /* ^U */ 173 | kill: 174 | wmove(win->x_win, win->x_line, 0); 175 | wclrtoeol(win->x_win); 176 | getyx(win->x_win, win->x_line, win->x_col); 177 | wrefresh(win->x_win); 178 | return; 179 | 180 | case L'\f': 181 | if (win == &my_win) 182 | wrefresh(curscr); 183 | return; 184 | 185 | case L'\7': 186 | write(STDOUT_FILENO, wc, sizeof(*wc)); 187 | return; 188 | } 189 | 190 | 191 | if (iswprint(*wc) || *wc == L'\t') 192 | wadd_wch(win->x_win, makecchar(*wc)); 193 | else 194 | beep(); 195 | 196 | getyx(win->x_win, win->x_line, win->x_col); 197 | wrefresh(win->x_win); 198 | } 199 | 200 | /* 201 | * Read the character at the indicated position in win 202 | */ 203 | int 204 | readwin(WINDOW *win, int line, int col) 205 | { 206 | int oldline, oldcol; 207 | int c; 208 | 209 | getyx(win, oldline, oldcol); 210 | wmove(win, line, col); 211 | c = winch(win); 212 | wmove(win, oldline, oldcol); 213 | return (c); 214 | } 215 | -------------------------------------------------------------------------------- /telnet/terminal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1988, 1990, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | 34 | #if 0 35 | #ifndef lint 36 | static const char sccsid[] = "@(#)terminal.c 8.2 (Berkeley) 2/16/95"; 37 | #endif 38 | #endif 39 | #include 40 | __FBSDID("$FreeBSD: src/contrib/telnet/telnet/terminal.c,v 1.7 2003/05/04 02:54:48 obrien Exp $"); 41 | 42 | #include 43 | #include 44 | 45 | #include 46 | 47 | #include "ring.h" 48 | 49 | #include "externs.h" 50 | #include "types.h" 51 | 52 | #ifdef ENCRYPTION 53 | #include 54 | #endif 55 | 56 | Ring ttyoring, ttyiring; 57 | unsigned char ttyobuf[2*BUFSIZ], ttyibuf[BUFSIZ]; 58 | 59 | int termdata; /* Debugging flag */ 60 | 61 | #ifdef USE_TERMIO 62 | # ifndef VDISCARD 63 | cc_t termFlushChar; 64 | # endif 65 | # ifndef VLNEXT 66 | cc_t termLiteralNextChar; 67 | # endif 68 | # ifndef VSUSP 69 | cc_t termSuspChar; 70 | # endif 71 | # ifndef VWERASE 72 | cc_t termWerasChar; 73 | # endif 74 | # ifndef VREPRINT 75 | cc_t termRprntChar; 76 | # endif 77 | # ifndef VSTART 78 | cc_t termStartChar; 79 | # endif 80 | # ifndef VSTOP 81 | cc_t termStopChar; 82 | # endif 83 | # ifndef VEOL 84 | cc_t termForw1Char; 85 | # endif 86 | # ifndef VEOL2 87 | cc_t termForw2Char; 88 | # endif 89 | # ifndef VSTATUS 90 | cc_t termAytChar; 91 | # endif 92 | #else 93 | cc_t termForw2Char; 94 | cc_t termAytChar; 95 | #endif 96 | 97 | /* 98 | * initialize the terminal data structures. 99 | */ 100 | 101 | void 102 | init_terminal(void) 103 | { 104 | if (ring_init(&ttyoring, ttyobuf, sizeof ttyobuf) != 1) { 105 | exit(1); 106 | } 107 | if (ring_init(&ttyiring, ttyibuf, sizeof ttyibuf) != 1) { 108 | exit(1); 109 | } 110 | autoflush = TerminalAutoFlush(); 111 | } 112 | 113 | /* 114 | * Send as much data as possible to the terminal. 115 | * 116 | * Return value: 117 | * -1: No useful work done, data waiting to go out. 118 | * 0: No data was waiting, so nothing was done. 119 | * 1: All waiting data was written out. 120 | * n: All data - n was written out. 121 | */ 122 | 123 | int 124 | ttyflush(int drop) 125 | { 126 | int n, n0, n1; 127 | 128 | n0 = ring_full_count(&ttyoring); 129 | if ((n1 = n = ring_full_consecutive(&ttyoring)) > 0) { 130 | if (drop) { 131 | TerminalFlushOutput(); 132 | /* we leave 'n' alone! */ 133 | } else { 134 | n = TerminalWrite((char *)ttyoring.consume, n); 135 | } 136 | } 137 | if (n > 0) { 138 | if (termdata && n) { 139 | Dump('>', ttyoring.consume, n); 140 | } 141 | /* 142 | * If we wrote everything, and the full count is 143 | * larger than what we wrote, then write the 144 | * rest of the buffer. 145 | */ 146 | if (n1 == n && n0 > n) { 147 | n1 = n0 - n; 148 | if (!drop) 149 | n1 = TerminalWrite((char *)ttyoring.bottom, n1); 150 | if (n1 > 0) 151 | n += n1; 152 | } 153 | ring_consumed(&ttyoring, n); 154 | } 155 | if (n < 0) 156 | return -1; 157 | if (n == n0) { 158 | if (n0) 159 | return -1; 160 | return 0; 161 | } 162 | return n0 - n + 1; 163 | } 164 | 165 | 166 | /* 167 | * These routines decides on what the mode should be (based on the values 168 | * of various global variables). 169 | */ 170 | 171 | 172 | int 173 | getconnmode(void) 174 | { 175 | extern int linemode; 176 | int mode = 0; 177 | #ifdef KLUDGELINEMODE 178 | extern int kludgelinemode; 179 | #endif 180 | 181 | if (my_want_state_is_dont(TELOPT_ECHO)) 182 | mode |= MODE_ECHO; 183 | 184 | if (localflow) 185 | mode |= MODE_FLOW; 186 | 187 | if (my_want_state_is_will(TELOPT_BINARY)) 188 | mode |= MODE_INBIN; 189 | 190 | if (his_want_state_is_will(TELOPT_BINARY)) 191 | mode |= MODE_OUTBIN; 192 | 193 | #ifdef KLUDGELINEMODE 194 | if (kludgelinemode) { 195 | if (my_want_state_is_dont(TELOPT_SGA)) { 196 | mode |= (MODE_TRAPSIG|MODE_EDIT); 197 | if (dontlecho && (clocks.echotoggle > clocks.modenegotiated)) { 198 | mode &= ~MODE_ECHO; 199 | } 200 | } 201 | return(mode); 202 | } 203 | #endif 204 | if (my_want_state_is_will(TELOPT_LINEMODE)) 205 | mode |= linemode; 206 | return(mode); 207 | } 208 | 209 | void 210 | setconnmode(int force) 211 | { 212 | #ifdef ENCRYPTION 213 | static int enc_passwd = 0; 214 | #endif /* ENCRYPTION */ 215 | int newmode; 216 | 217 | newmode = getconnmode()|(force?MODE_FORCE:0); 218 | 219 | TerminalNewMode(newmode); 220 | 221 | #ifdef ENCRYPTION 222 | if ((newmode & (MODE_ECHO|MODE_EDIT)) == MODE_EDIT) { 223 | if (my_want_state_is_will(TELOPT_ENCRYPT) 224 | && (enc_passwd == 0) && !encrypt_output) { 225 | encrypt_request_start(0, 0); 226 | enc_passwd = 1; 227 | } 228 | } else { 229 | if (enc_passwd) { 230 | encrypt_request_end(); 231 | enc_passwd = 0; 232 | } 233 | } 234 | #endif /* ENCRYPTION */ 235 | 236 | } 237 | 238 | void 239 | setcommandmode(void) 240 | { 241 | TerminalNewMode(-1); 242 | } 243 | -------------------------------------------------------------------------------- /talk/invite.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | #ifndef __APPLE__ 35 | __FBSDID("$FreeBSD$"); 36 | 37 | #ifndef lint 38 | static const char sccsid[] = "@(#)invite.c 8.1 (Berkeley) 6/6/93"; 39 | #endif 40 | #endif /* __APPLE__ */ 41 | 42 | #include 43 | #include 44 | #include 45 | 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | #include "talk_ctl.h" 53 | #include "talk.h" 54 | 55 | /* 56 | * There wasn't an invitation waiting, so send a request containing 57 | * our sockt address to the remote talk daemon so it can invite 58 | * him 59 | */ 60 | 61 | /* 62 | * The msg.id's for the invitations 63 | * on the local and remote machines. 64 | * These are used to delete the 65 | * invitations. 66 | */ 67 | static int local_id, remote_id; 68 | static jmp_buf invitebuf; 69 | 70 | void 71 | invite_remote(void) 72 | { 73 | int new_sockt; 74 | struct itimerval itimer; 75 | CTL_RESPONSE response; 76 | 77 | itimer.it_value.tv_sec = RING_WAIT; 78 | itimer.it_value.tv_usec = 0; 79 | itimer.it_interval = itimer.it_value; 80 | if (listen(sockt, 5) != 0) 81 | p_error("Error on attempt to listen for caller"); 82 | /* copy new style sockaddr to old, swap family (short in old) */ 83 | msg.addr = *(struct tsockaddr *)&my_addr; 84 | msg.addr.sa_family = htons(my_addr.sin_family); 85 | msg.id_num = htonl(-1); /* an impossible id_num */ 86 | invitation_waiting = 1; 87 | announce_invite(); 88 | /* 89 | * Shut off the automatic messages for a while, 90 | * so we can use the interrupt timer to resend the invitation 91 | */ 92 | end_msgs(); 93 | setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0); 94 | message("Waiting for your party to respond"); 95 | signal(SIGALRM, re_invite); 96 | (void) setjmp(invitebuf); 97 | while ((new_sockt = accept(sockt, 0, 0)) < 0) { 98 | if (errno == EINTR) 99 | continue; 100 | p_error("Unable to connect with your party"); 101 | } 102 | close(sockt); 103 | sockt = new_sockt; 104 | 105 | /* 106 | * Have the daemons delete the invitations now that we 107 | * have connected. 108 | */ 109 | current_state = "Waiting for your party to respond"; 110 | start_msgs(); 111 | 112 | msg.id_num = htonl(local_id); 113 | ctl_transact(my_machine_addr, msg, DELETE, &response); 114 | msg.id_num = htonl(remote_id); 115 | ctl_transact(his_machine_addr, msg, DELETE, &response); 116 | invitation_waiting = 0; 117 | } 118 | 119 | /* 120 | * Routine called on interrupt to re-invite the callee 121 | */ 122 | /* ARGSUSED */ 123 | void 124 | re_invite(int signo __unused) 125 | { 126 | 127 | message("Ringing your party again"); 128 | waddch(my_win.x_win, '\n'); 129 | if (current_line < my_win.x_nlines - 1) 130 | current_line++; 131 | /* force a re-announce */ 132 | msg.id_num = htonl(remote_id + 1); 133 | announce_invite(); 134 | longjmp(invitebuf, 1); 135 | } 136 | 137 | static const char *answers[] = { 138 | "answer #0", /* SUCCESS */ 139 | "Your party is not logged on", /* NOT_HERE */ 140 | "Target machine is too confused to talk to us", /* FAILED */ 141 | "Target machine does not recognize us", /* MACHINE_UNKNOWN */ 142 | "Your party is refusing messages", /* PERMISSION_REFUSED */ 143 | "Target machine can not handle remote talk", /* UNKNOWN_REQUEST */ 144 | "Target machine indicates protocol mismatch", /* BADVERSION */ 145 | "Target machine indicates protocol botch (addr)",/* BADADDR */ 146 | "Target machine indicates protocol botch (ctl_addr)",/* BADCTLADDR */ 147 | }; 148 | #define NANSWERS (sizeof (answers) / sizeof (answers[0])) 149 | 150 | /* 151 | * Transmit the invitation and process the response 152 | */ 153 | void 154 | announce_invite(void) 155 | { 156 | CTL_RESPONSE response; 157 | 158 | current_state = "Trying to connect to your party's talk daemon"; 159 | ctl_transact(his_machine_addr, msg, ANNOUNCE, &response); 160 | remote_id = response.id_num; 161 | if (response.answer != SUCCESS) { 162 | if (response.answer < NANSWERS) 163 | message(answers[response.answer]); 164 | quit(); 165 | } 166 | /* leave the actual invitation on my talk daemon */ 167 | current_state = "Trying to connect to local talk daemon"; 168 | ctl_transact(my_machine_addr, msg, LEAVE_INVITE, &response); 169 | local_id = response.id_num; 170 | } 171 | 172 | /* 173 | * Tell the daemon to remove your invitation 174 | */ 175 | void 176 | send_delete(void) 177 | { 178 | 179 | msg.type = DELETE; 180 | /* 181 | * This is just an extra clean up, so just send it 182 | * and don't wait for an answer 183 | */ 184 | msg.id_num = htonl(remote_id); 185 | daemon_addr.sin_addr = his_machine_addr; 186 | if (sendto(ctl_sockt, &msg, sizeof (msg), 0, 187 | (struct sockaddr *)&daemon_addr, 188 | sizeof (daemon_addr)) != sizeof(msg)) 189 | warn("send_delete (remote)"); 190 | msg.id_num = htonl(local_id); 191 | daemon_addr.sin_addr = my_machine_addr; 192 | if (sendto(ctl_sockt, &msg, sizeof (msg), 0, 193 | (struct sockaddr *)&daemon_addr, 194 | sizeof (daemon_addr)) != sizeof (msg)) 195 | warn("send_delete (local)"); 196 | } 197 | -------------------------------------------------------------------------------- /talkd/process.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | #if 0 34 | static char sccsid[] = "@(#)process.c 8.2 (Berkeley) 11/16/93"; 35 | #endif 36 | __attribute__((__used__)) 37 | static const char rcsid[] = 38 | "$FreeBSD$"; 39 | #endif /* not lint */ 40 | 41 | /* 42 | * process.c handles the requests, which can be of three types: 43 | * ANNOUNCE - announce to a user that a talk is wanted 44 | * LEAVE_INVITE - insert the request into the table 45 | * LOOK_UP - look up to see if a request is waiting in 46 | * in the table for the local user 47 | * DELETE - delete invitation 48 | */ 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | 63 | #include "extern.h" 64 | 65 | void 66 | process_request(CTL_MSG *mp, CTL_RESPONSE *rp) 67 | { 68 | CTL_MSG *ptr; 69 | char *s; 70 | 71 | rp->vers = TALK_VERSION; 72 | rp->type = mp->type; 73 | rp->id_num = htonl(0); 74 | if (mp->vers != TALK_VERSION) { 75 | syslog(LOG_WARNING, "bad protocol version %d", mp->vers); 76 | rp->answer = BADVERSION; 77 | return; 78 | } 79 | mp->id_num = ntohl(mp->id_num); 80 | mp->addr.sa_family = ntohs(mp->addr.sa_family); 81 | if (mp->addr.sa_family != AF_INET) { 82 | syslog(LOG_WARNING, "bad address, family %d", 83 | mp->addr.sa_family); 84 | rp->answer = BADADDR; 85 | return; 86 | } 87 | mp->ctl_addr.sa_family = ntohs(mp->ctl_addr.sa_family); 88 | if (mp->ctl_addr.sa_family != AF_INET) { 89 | syslog(LOG_WARNING, "bad control address, family %d", 90 | mp->ctl_addr.sa_family); 91 | rp->answer = BADCTLADDR; 92 | return; 93 | } 94 | for (s = mp->l_name; *s; s++) 95 | if (!isprint(*s)) { 96 | syslog(LOG_NOTICE, "illegal user name. Aborting"); 97 | rp->answer = FAILED; 98 | return; 99 | } 100 | mp->pid = ntohl(mp->pid); 101 | if (debug) 102 | print_request("process_request", mp); 103 | switch (mp->type) { 104 | 105 | case ANNOUNCE: 106 | do_announce(mp, rp); 107 | break; 108 | 109 | case LEAVE_INVITE: 110 | ptr = find_request(mp); 111 | if (ptr != (CTL_MSG *)0) { 112 | rp->id_num = htonl(ptr->id_num); 113 | rp->answer = SUCCESS; 114 | } else 115 | insert_table(mp, rp); 116 | break; 117 | 118 | case LOOK_UP: 119 | ptr = find_match(mp); 120 | if (ptr != (CTL_MSG *)0) { 121 | rp->id_num = htonl(ptr->id_num); 122 | rp->addr = ptr->addr; 123 | rp->addr.sa_family = htons(ptr->addr.sa_family); 124 | rp->answer = SUCCESS; 125 | } else 126 | rp->answer = NOT_HERE; 127 | break; 128 | 129 | case DELETE: 130 | rp->answer = delete_invite(mp->id_num); 131 | break; 132 | 133 | default: 134 | rp->answer = UNKNOWN_REQUEST; 135 | break; 136 | } 137 | if (debug) 138 | print_response("process_request", rp); 139 | } 140 | 141 | void 142 | do_announce(CTL_MSG *mp, CTL_RESPONSE *rp) 143 | { 144 | struct hostent *hp; 145 | CTL_MSG *ptr; 146 | int result; 147 | 148 | /* see if the user is logged */ 149 | result = find_user(mp->r_name, mp->r_tty); 150 | if (result != SUCCESS) { 151 | rp->answer = result; 152 | return; 153 | } 154 | #define satosin(sa) ((struct sockaddr_in *)(void *)(sa)) 155 | hp = gethostbyaddr(&satosin(&mp->ctl_addr)->sin_addr, 156 | sizeof (struct in_addr), AF_INET); 157 | if (hp == (struct hostent *)0) { 158 | rp->answer = MACHINE_UNKNOWN; 159 | return; 160 | } 161 | ptr = find_request(mp); 162 | if (ptr == (CTL_MSG *) 0) { 163 | insert_table(mp, rp); 164 | rp->answer = announce(mp, hp->h_name); 165 | return; 166 | } 167 | if (mp->id_num > ptr->id_num) { 168 | /* 169 | * This is an explicit re-announce, so update the id_num 170 | * field to avoid duplicates and re-announce the talk. 171 | */ 172 | ptr->id_num = new_id(); 173 | rp->id_num = htonl(ptr->id_num); 174 | rp->answer = announce(mp, hp->h_name); 175 | } else { 176 | /* a duplicated request, so ignore it */ 177 | rp->id_num = htonl(ptr->id_num); 178 | rp->answer = SUCCESS; 179 | } 180 | } 181 | 182 | /* 183 | * Search utmp for the local user 184 | */ 185 | int 186 | find_user(const char *name, char *tty) 187 | { 188 | struct utmpx *ut; 189 | int status; 190 | struct stat statb; 191 | time_t best = 0; 192 | char ftty[sizeof(_PATH_DEV) - 1 + sizeof(ut->ut_line)]; 193 | 194 | setutxent(); 195 | status = NOT_HERE; 196 | (void) strcpy(ftty, _PATH_DEV); 197 | while ((ut = getutxent()) != NULL) 198 | if (ut->ut_type == USER_PROCESS && 199 | strcmp(ut->ut_user, name) == 0) { 200 | if (*tty == '\0' || best != 0) { 201 | if (best == 0) 202 | status = PERMISSION_DENIED; 203 | /* no particular tty was requested */ 204 | (void) strcpy(ftty + sizeof(_PATH_DEV) - 1, 205 | ut->ut_line); 206 | if (stat(ftty, &statb) == 0) { 207 | if (!(statb.st_mode & 020)) 208 | continue; 209 | if (statb.st_atime > best) { 210 | best = statb.st_atime; 211 | (void) strcpy(tty, ut->ut_line); 212 | status = SUCCESS; 213 | continue; 214 | } 215 | } 216 | } 217 | if (strcmp(ut->ut_line, tty) == 0) { 218 | status = SUCCESS; 219 | break; 220 | } 221 | } 222 | endutxent(); 223 | return (status); 224 | } 225 | -------------------------------------------------------------------------------- /talk/init_disp.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | #ifndef __APPLE__ 35 | __FBSDID("$FreeBSD$"); 36 | 37 | #ifndef lint 38 | static const char sccsid[] = "@(#)init_disp.c 8.2 (Berkeley) 2/16/94"; 39 | #endif 40 | #endif /* __APPLE__ */ 41 | 42 | /* 43 | * Initialization code for the display package, 44 | * as well as the signal handling routines. 45 | */ 46 | 47 | #include 48 | #ifdef __APPLE__ 49 | #include 50 | #endif 51 | 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | 58 | #include "talk.h" 59 | 60 | /* 61 | * Make sure the callee can write to the screen 62 | */ 63 | void 64 | check_writeable(void) 65 | { 66 | char *tty; 67 | struct stat sb; 68 | 69 | if ((tty = ttyname(STDERR_FILENO)) == NULL) 70 | err(1, "ttyname"); 71 | if (stat(tty, &sb) < 0) 72 | err(1, "%s", tty); 73 | if (!(sb.st_mode & S_IWGRP)) 74 | errx(1, "The callee cannot write to this terminal, use \"mesg y\"."); 75 | } 76 | 77 | /* 78 | * Set up curses, catch the appropriate signals, 79 | * and build the various windows. 80 | */ 81 | void 82 | init_display(void) 83 | { 84 | struct sigaction sa; 85 | 86 | if (initscr() == NULL) 87 | errx(1, "Terminal type unset or lacking necessary features."); 88 | (void) sigaction(SIGTSTP, (struct sigaction *)0, &sa); 89 | sigaddset(&sa.sa_mask, SIGALRM); 90 | (void) sigaction(SIGTSTP, &sa, (struct sigaction *)0); 91 | curses_initialized = 1; 92 | clear(); 93 | refresh(); 94 | noecho(); 95 | crmode(); 96 | signal(SIGINT, sig_sent); 97 | signal(SIGPIPE, sig_sent); 98 | signal(SIGWINCH, sig_winch); 99 | /* curses takes care of ^Z */ 100 | my_win.x_nlines = LINES / 2; 101 | my_win.x_ncols = COLS; 102 | my_win.x_win = newwin(my_win.x_nlines, my_win.x_ncols, 0, 0); 103 | idlok(my_win.x_win, TRUE); 104 | scrollok(my_win.x_win, TRUE); 105 | wclear(my_win.x_win); 106 | 107 | his_win.x_nlines = LINES / 2 - 1; 108 | his_win.x_ncols = COLS; 109 | his_win.x_win = newwin(his_win.x_nlines, his_win.x_ncols, 110 | my_win.x_nlines+1, 0); 111 | idlok(my_win.x_win, TRUE); 112 | scrollok(his_win.x_win, TRUE); 113 | wclear(his_win.x_win); 114 | 115 | line_win = newwin(1, COLS, my_win.x_nlines, 0); 116 | #if defined(hline) || defined(whline) || defined(NCURSES_VERSION) 117 | whline(line_win, 0, COLS); 118 | #else 119 | box(line_win, '-', '-'); 120 | #endif 121 | wrefresh(line_win); 122 | /* let them know we are working on it */ 123 | current_state = "No connection yet"; 124 | } 125 | 126 | /* 127 | * Trade edit characters with the other talk. By agreement 128 | * the first three characters each talk transmits after 129 | * connection are the three edit characters. 130 | */ 131 | void 132 | set_edit_chars(void) 133 | { 134 | char buf[3]; 135 | int cc; 136 | struct termios tio; 137 | 138 | tcgetattr(0, &tio); 139 | my_win.cerase = tio.c_cc[VERASE]; 140 | my_win.kill = tio.c_cc[VKILL]; 141 | my_win.werase = tio.c_cc[VWERASE]; 142 | if (my_win.cerase == (char)_POSIX_VDISABLE) 143 | my_win.kill = CERASE; 144 | if (my_win.kill == (char)_POSIX_VDISABLE) 145 | my_win.kill = CKILL; 146 | if (my_win.werase == (char)_POSIX_VDISABLE) 147 | my_win.werase = CWERASE; 148 | buf[0] = my_win.cerase; 149 | buf[1] = my_win.kill; 150 | buf[2] = my_win.werase; 151 | cc = write(sockt, buf, sizeof(buf)); 152 | if (cc != sizeof(buf) ) 153 | p_error("Lost the connection"); 154 | cc = read(sockt, buf, sizeof(buf)); 155 | if (cc != sizeof(buf) ) 156 | p_error("Lost the connection"); 157 | his_win.cerase = buf[0]; 158 | his_win.kill = buf[1]; 159 | his_win.werase = buf[2]; 160 | } 161 | 162 | /* ARGSUSED */ 163 | void 164 | sig_sent(int signo __unused) 165 | { 166 | 167 | message("Connection closing. Exiting"); 168 | quit(); 169 | } 170 | 171 | void 172 | sig_winch(int dummy __unused) 173 | { 174 | 175 | gotwinch = 1; 176 | } 177 | 178 | /* 179 | * All done talking...hang up the phone and reset terminal thingy's 180 | */ 181 | void 182 | quit(void) 183 | { 184 | 185 | if (curses_initialized) { 186 | wmove(his_win.x_win, his_win.x_nlines-1, 0); 187 | wclrtoeol(his_win.x_win); 188 | wrefresh(his_win.x_win); 189 | endwin(); 190 | } 191 | if (invitation_waiting) 192 | send_delete(); 193 | exit(0); 194 | } 195 | 196 | /* 197 | * If we get SIGWINCH, recompute both window sizes and refresh things. 198 | */ 199 | void 200 | resize_display(void) 201 | { 202 | struct winsize ws; 203 | 204 | if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) < 0 || 205 | (ws.ws_row == LINES && ws.ws_col == COLS)) 206 | return; 207 | 208 | /* Update curses' internal state with new window size. */ 209 | resizeterm(ws.ws_row, ws.ws_col); 210 | 211 | /* 212 | * Resize each window but wait to refresh the screen until 213 | * everything has been drawn so the cursor is in the right spot. 214 | */ 215 | my_win.x_nlines = LINES / 2; 216 | my_win.x_ncols = COLS; 217 | wresize(my_win.x_win, my_win.x_nlines, my_win.x_ncols); 218 | mvwin(my_win.x_win, 0, 0); 219 | clearok(my_win.x_win, TRUE); 220 | 221 | his_win.x_nlines = LINES / 2 - 1; 222 | his_win.x_ncols = COLS; 223 | wresize(his_win.x_win, his_win.x_nlines, his_win.x_ncols); 224 | mvwin(his_win.x_win, my_win.x_nlines + 1, 0); 225 | clearok(his_win.x_win, TRUE); 226 | 227 | wresize(line_win, 1, COLS); 228 | mvwin(line_win, my_win.x_nlines, 0); 229 | #if defined(NCURSES_VERSION) || defined(whline) 230 | whline(line_win, '-', COLS); 231 | #else 232 | wmove(line_win, my_win.x_nlines, 0); 233 | box(line_win, '-', '-'); 234 | #endif 235 | 236 | /* Now redraw the screen. */ 237 | wrefresh(his_win.x_win); 238 | wrefresh(line_win); 239 | wrefresh(my_win.x_win); 240 | } 241 | -------------------------------------------------------------------------------- /tftpd/tftp-file.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause 3 | * 4 | * Copyright (C) 2008 Edwin Groothuis. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #include "tftp-file.h" 45 | #include "tftp-utils.h" 46 | 47 | static FILE *file; 48 | static int convert; 49 | 50 | static char convbuffer[66000]; 51 | static int gotcr = 0; 52 | 53 | static size_t 54 | convert_from_net(char *buffer, size_t count) 55 | { 56 | size_t i, n; 57 | 58 | /* 59 | * Convert all CR/LF to LF and all CR,NUL to CR 60 | */ 61 | 62 | n = 0; 63 | for (i = 0; i < count; i++) { 64 | 65 | if (gotcr == 0) { 66 | convbuffer[n++] = buffer[i]; 67 | gotcr = (buffer[i] == '\r'); 68 | continue; 69 | } 70 | 71 | /* CR, NULL -> CR */ 72 | if (buffer[i] == '\0') { 73 | gotcr = 0; 74 | continue; 75 | } 76 | 77 | /* CR, LF -> LF */ 78 | if (buffer[i] == '\n') { 79 | if (n == 0) { 80 | if (ftell(file) != 0) { 81 | int r = fseek(file, -1, SEEK_END); 82 | assert(r == 0); 83 | convbuffer[n++] = '\n'; 84 | } else { 85 | /* This shouldn't happen */ 86 | tftp_log(LOG_ERR, 87 | "Received LF as first character"); 88 | abort(); 89 | } 90 | } else 91 | convbuffer[n-1] = '\n'; 92 | gotcr = 0; 93 | continue; 94 | } 95 | 96 | /* Everything else just accept as is */ 97 | convbuffer[n++] = buffer[i]; 98 | gotcr = (buffer[i] == '\r'); 99 | continue; 100 | } 101 | 102 | return fwrite(convbuffer, 1, n, file); 103 | } 104 | 105 | static size_t 106 | convert_to_net(char *buffer, size_t count, int init) 107 | { 108 | size_t i; 109 | static size_t n = 0, in = 0; 110 | static int newline = -1; 111 | 112 | if (init) { 113 | newline = -1; 114 | n = 0; 115 | in = 0; 116 | return 0 ; 117 | } 118 | 119 | /* 120 | * Convert all LF to CR,LF and all CR to CR,NUL 121 | */ 122 | i = 0; 123 | 124 | if (newline != -1) { 125 | buffer[i++] = newline; 126 | newline = -1; 127 | } 128 | 129 | while (i < count) { 130 | if (n == in) { 131 | /* When done we're done */ 132 | if (feof(file)) break; 133 | 134 | /* Otherwise read another bunch */ 135 | in = fread(convbuffer, 1, count, file); 136 | if (in == 0) break; 137 | n = 0; 138 | } 139 | 140 | /* CR -> CR,NULL */ 141 | if (convbuffer[n] == '\r') { 142 | buffer[i++] = '\r'; 143 | buffer[i++] = '\0'; 144 | n++; 145 | continue; 146 | } 147 | 148 | /* LF -> CR,LF */ 149 | if (convbuffer[n] == '\n') { 150 | buffer[i++] = '\r'; 151 | buffer[i++] = '\n'; 152 | n++; 153 | continue; 154 | } 155 | 156 | buffer[i++] = convbuffer[n++]; 157 | } 158 | 159 | if (i > count) { 160 | /* 161 | * Whoops... that isn't allowed (but it will happen 162 | * when there is a CR or LF at the end of the buffer) 163 | */ 164 | newline = buffer[i-1]; 165 | } 166 | 167 | if (i < count) { 168 | /* We are done! */ 169 | return i; 170 | } else 171 | return count; 172 | 173 | } 174 | 175 | int 176 | write_init(int fd, FILE *f, const char *mode) 177 | { 178 | 179 | if (f == NULL) { 180 | file = fdopen(fd, "w"); 181 | if (file == NULL) { 182 | int en = errno; 183 | tftp_log(LOG_ERR, "fdopen() failed: %s", 184 | strerror(errno)); 185 | return en; 186 | } 187 | } else 188 | file = f; 189 | convert = !strcmp(mode, "netascii"); 190 | return 0; 191 | } 192 | 193 | size_t 194 | write_file(char *buffer, int count) 195 | { 196 | 197 | if (convert == 0) 198 | return fwrite(buffer, 1, count, file); 199 | 200 | return convert_from_net(buffer, count); 201 | } 202 | 203 | int 204 | write_close(void) 205 | { 206 | 207 | if (fclose(file) != 0) { 208 | tftp_log(LOG_ERR, "fclose() failed: %s", strerror(errno)); 209 | return 1; 210 | } 211 | return 0; 212 | } 213 | 214 | off_t 215 | tell_file(void) 216 | { 217 | 218 | return ftello(file); 219 | } 220 | 221 | int 222 | seek_file(off_t offset) 223 | { 224 | 225 | return fseeko(file, offset, SEEK_SET); 226 | } 227 | 228 | int 229 | read_init(int fd, FILE *f, const char *mode) 230 | { 231 | 232 | convert_to_net(NULL, 0, 1); 233 | if (f == NULL) { 234 | file = fdopen(fd, "r"); 235 | if (file == NULL) { 236 | int en = errno; 237 | tftp_log(LOG_ERR, "fdopen() failed: %s", 238 | strerror(errno)); 239 | return en; 240 | } 241 | } else 242 | file = f; 243 | convert = !strcmp(mode, "netascii"); 244 | return 0; 245 | } 246 | 247 | size_t 248 | read_file(char *buffer, int count) 249 | { 250 | 251 | if (convert == 0) 252 | return fread(buffer, 1, count, file); 253 | 254 | return convert_to_net(buffer, count, 0); 255 | } 256 | 257 | int 258 | read_close(void) 259 | { 260 | 261 | if (fclose(file) != 0) { 262 | tftp_log(LOG_ERR, "fclose() failed: %s", strerror(errno)); 263 | return 1; 264 | } 265 | return 0; 266 | } 267 | 268 | 269 | /* When an error has occurred, it is possible that the two sides 270 | * are out of synch. Ie: that what I think is the other side's 271 | * response to packet N is really their response to packet N-1. 272 | * 273 | * So, to try to prevent that, we flush all the input queued up 274 | * for us on the network connection on our host. 275 | * 276 | * We return the number of packets we flushed (mostly for reporting 277 | * when trace is active). 278 | */ 279 | 280 | int 281 | synchnet(int peer) /* socket to flush */ 282 | { 283 | int i, j = 0; 284 | char rbuf[MAXPKTSIZE]; 285 | struct sockaddr_storage from; 286 | socklen_t fromlen; 287 | 288 | while (1) { 289 | (void) ioctl(peer, FIONREAD, &i); 290 | if (i) { 291 | j++; 292 | fromlen = sizeof from; 293 | (void) recvfrom(peer, rbuf, sizeof (rbuf), 0, 294 | (struct sockaddr *)&from, &fromlen); 295 | } else { 296 | return(j); 297 | } 298 | } 299 | } 300 | -------------------------------------------------------------------------------- /talkd/table.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1983, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | #if 0 34 | static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/4/93"; 35 | #endif 36 | __attribute__((__used__)) 37 | static const char rcsid[] = 38 | "$FreeBSD$"; 39 | #endif /* not lint */ 40 | 41 | /* 42 | * Routines to handle insertion, deletion, etc on the table 43 | * of requests kept by the daemon. Nothing fancy here, linear 44 | * search on a double-linked list. A time is kept with each 45 | * entry so that overly old invitations can be eliminated. 46 | * 47 | * Consider this a mis-guided attempt at modularity 48 | */ 49 | #include 50 | #include 51 | #ifdef __APPLE__ 52 | #ifndef CLOCK_MONOTONIC_FAST 53 | #define CLOCK_MONOTONIC_FAST CLOCK_MONOTONIC 54 | #endif 55 | #endif /* __APPLE__ */ 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | 65 | #include "extern.h" 66 | 67 | #define MAX_ID 16000 /* << 2^15 so I don't have sign troubles */ 68 | 69 | #define NIL ((TABLE_ENTRY *)0) 70 | 71 | static struct timespec ts; 72 | 73 | typedef struct table_entry TABLE_ENTRY; 74 | 75 | struct table_entry { 76 | CTL_MSG request; 77 | long time; 78 | TABLE_ENTRY *next; 79 | TABLE_ENTRY *last; 80 | }; 81 | 82 | static void delete(TABLE_ENTRY *); 83 | 84 | static TABLE_ENTRY *table = NIL; 85 | 86 | /* 87 | * Look in the table for an invitation that matches the current 88 | * request looking for an invitation 89 | */ 90 | CTL_MSG * 91 | find_match(CTL_MSG *request) 92 | { 93 | TABLE_ENTRY *ptr, *next; 94 | time_t current_time; 95 | 96 | clock_gettime(CLOCK_MONOTONIC_FAST, &ts); 97 | current_time = ts.tv_sec; 98 | if (debug) 99 | print_request("find_match", request); 100 | for (ptr = table; ptr != NIL; ptr = next) { 101 | next = ptr->next; 102 | if ((ptr->time - current_time) > MAX_LIFE) { 103 | /* the entry is too old */ 104 | if (debug) 105 | print_request("deleting expired entry", 106 | &ptr->request); 107 | delete(ptr); 108 | continue; 109 | } 110 | if (debug) 111 | print_request("", &ptr->request); 112 | if (strcmp(request->l_name, ptr->request.r_name) == 0 && 113 | strcmp(request->r_name, ptr->request.l_name) == 0 && 114 | ptr->request.type == LEAVE_INVITE) 115 | return (&ptr->request); 116 | } 117 | return ((CTL_MSG *)0); 118 | } 119 | 120 | /* 121 | * Look for an identical request, as opposed to a complimentary 122 | * one as find_match does 123 | */ 124 | CTL_MSG * 125 | find_request(CTL_MSG *request) 126 | { 127 | TABLE_ENTRY *ptr, *next; 128 | time_t current_time; 129 | 130 | clock_gettime(CLOCK_MONOTONIC_FAST, &ts); 131 | current_time = ts.tv_sec; 132 | /* 133 | * See if this is a repeated message, and check for 134 | * out of date entries in the table while we are it. 135 | */ 136 | if (debug) 137 | print_request("find_request", request); 138 | for (ptr = table; ptr != NIL; ptr = next) { 139 | next = ptr->next; 140 | if ((ptr->time - current_time) > MAX_LIFE) { 141 | /* the entry is too old */ 142 | if (debug) 143 | print_request("deleting expired entry", 144 | &ptr->request); 145 | delete(ptr); 146 | continue; 147 | } 148 | if (debug) 149 | print_request("", &ptr->request); 150 | if (strcmp(request->r_name, ptr->request.r_name) == 0 && 151 | strcmp(request->l_name, ptr->request.l_name) == 0 && 152 | request->type == ptr->request.type && 153 | request->pid == ptr->request.pid) { 154 | /* update the time if we 'touch' it */ 155 | ptr->time = current_time; 156 | return (&ptr->request); 157 | } 158 | } 159 | return ((CTL_MSG *)0); 160 | } 161 | 162 | void 163 | insert_table(CTL_MSG *request, CTL_RESPONSE *response) 164 | { 165 | TABLE_ENTRY *ptr; 166 | time_t current_time; 167 | 168 | clock_gettime(CLOCK_MONOTONIC_FAST, &ts); 169 | current_time = ts.tv_sec; 170 | request->id_num = new_id(); 171 | response->id_num = htonl(request->id_num); 172 | /* insert a new entry into the top of the list */ 173 | ptr = (TABLE_ENTRY *)malloc(sizeof(TABLE_ENTRY)); 174 | if (ptr == NIL) { 175 | syslog(LOG_ERR, "insert_table: Out of memory"); 176 | _exit(1); 177 | } 178 | ptr->time = current_time; 179 | ptr->request = *request; 180 | ptr->next = table; 181 | if (ptr->next != NIL) 182 | ptr->next->last = ptr; 183 | ptr->last = NIL; 184 | table = ptr; 185 | } 186 | 187 | /* 188 | * Generate a unique non-zero sequence number 189 | */ 190 | int 191 | new_id(void) 192 | { 193 | static int current_id = 0; 194 | 195 | current_id = (current_id + 1) % MAX_ID; 196 | /* 0 is reserved, helps to pick up bugs */ 197 | if (current_id == 0) 198 | current_id = 1; 199 | return (current_id); 200 | } 201 | 202 | /* 203 | * Delete the invitation with id 'id_num' 204 | */ 205 | int 206 | delete_invite(u_int32_t id_num) 207 | { 208 | TABLE_ENTRY *ptr; 209 | 210 | if (debug) 211 | syslog(LOG_DEBUG, "delete_invite(%d)", id_num); 212 | for (ptr = table; ptr != NIL; ptr = ptr->next) { 213 | if (ptr->request.id_num == id_num) 214 | break; 215 | if (debug) 216 | print_request("", &ptr->request); 217 | } 218 | if (ptr != NIL) { 219 | delete(ptr); 220 | return (SUCCESS); 221 | } 222 | return (NOT_HERE); 223 | } 224 | 225 | /* 226 | * Classic delete from a double-linked list 227 | */ 228 | static void 229 | delete(TABLE_ENTRY *ptr) 230 | { 231 | 232 | if (debug) 233 | print_request("delete", &ptr->request); 234 | if (table == ptr) 235 | table = ptr->next; 236 | else if (ptr->last != NIL) 237 | ptr->last->next = ptr->next; 238 | if (ptr->next != NIL) 239 | ptr->next->last = ptr->last; 240 | free((char *)ptr); 241 | } 242 | -------------------------------------------------------------------------------- /telnetd/ext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1989, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)ext.h 8.2 (Berkeley) 12/15/93 34 | * $FreeBSD: src/contrib/telnet/telnetd/ext.h,v 1.11 2001/11/30 22:28:07 markm Exp $ 35 | */ 36 | 37 | /* 38 | * Telnet server variable declarations 39 | */ 40 | extern char options[256]; 41 | extern char do_dont_resp[256]; 42 | extern char will_wont_resp[256]; 43 | extern int linemode; /* linemode on/off */ 44 | #ifdef LINEMODE 45 | extern int uselinemode; /* what linemode to use (on/off) */ 46 | extern int editmode; /* edit modes in use */ 47 | extern int useeditmode; /* edit modes to use */ 48 | extern int alwayslinemode; /* command line option */ 49 | extern int lmodetype; /* Client support for linemode */ 50 | #endif /* LINEMODE */ 51 | extern int flowmode; /* current flow control state */ 52 | extern int restartany; /* restart output on any character state */ 53 | #ifdef DIAGNOSTICS 54 | extern int diagnostic; /* telnet diagnostic capabilities */ 55 | #endif /* DIAGNOSTICS */ 56 | #ifdef BFTPDAEMON 57 | extern int bftpd; /* behave as bftp daemon */ 58 | #endif /* BFTPDAEMON */ 59 | #ifdef AUTHENTICATION 60 | extern int auth_level; 61 | #endif 62 | 63 | extern slcfun slctab[NSLC + 1]; /* slc mapping table */ 64 | 65 | extern char *terminaltype; 66 | 67 | /* 68 | * I/O data buffers, pointers, and counters. 69 | */ 70 | extern char ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp; 71 | 72 | extern char netibuf[BUFSIZ], *netip; 73 | 74 | extern char netobuf[BUFSIZ], *nfrontp, *nbackp; 75 | extern char *neturg; /* one past last bye of urgent data */ 76 | 77 | extern int pcc, ncc; 78 | 79 | extern int mpty, spty, net; 80 | extern char line[16]; 81 | extern int SYNCHing; /* we are in TELNET SYNCH mode */ 82 | 83 | extern void 84 | _termstat(void), 85 | add_slc(char, char, cc_t), 86 | check_slc(void), 87 | change_slc(char, char, cc_t), 88 | cleanup(int), 89 | clientstat(int, int, int), 90 | copy_termbuf(char *, size_t), 91 | deferslc(void), 92 | defer_terminit(void), 93 | do_opt_slc(unsigned char *, int), 94 | doeof(void), 95 | dooption(int), 96 | dontoption(int), 97 | edithost(char *, char *), 98 | fatal(int, const char *), 99 | fatalperror(int, const char *), 100 | get_slc_defaults(void), 101 | init_env(void), 102 | init_termbuf(void), 103 | interrupt(void), 104 | localstat(void), 105 | flowstat(void), 106 | netclear(void), 107 | netflush(void), 108 | #ifdef DIAGNOSTICS 109 | printoption(const char *, int), 110 | printdata(const char *, char *, int), 111 | printsub(char, unsigned char *, int), 112 | #endif 113 | process_slc(unsigned char, unsigned char, cc_t), 114 | ptyflush(void), 115 | putchr(int), 116 | putf(char *, char *), 117 | recv_ayt(void), 118 | send_do(int, int), 119 | send_dont(int, int), 120 | send_slc(void), 121 | send_status(void), 122 | send_will(int, int), 123 | send_wont(int, int), 124 | sendbrk(void), 125 | sendsusp(void), 126 | set_termbuf(void), 127 | start_login(char *, int, char *), 128 | start_slc(int), 129 | #ifdef AUTHENTICATION 130 | start_slave(char *), 131 | #else 132 | start_slave(char *, int, char *), 133 | #endif 134 | suboption(void), 135 | telrcv(void), 136 | ttloop(void), 137 | tty_binaryin(int), 138 | tty_binaryout(int); 139 | 140 | extern int 141 | end_slc(unsigned char **), 142 | getnpty(void), 143 | #ifndef convex 144 | getpty(int *, int *), 145 | #endif 146 | login_tty(int), 147 | spcset(int, cc_t *, cc_t **), 148 | stilloob(int), 149 | terminit(void), 150 | termstat(void), 151 | tty_flowmode(void), 152 | tty_restartany(void), 153 | tty_isbinaryin(void), 154 | tty_isbinaryout(void), 155 | tty_iscrnl(void), 156 | tty_isecho(void), 157 | tty_isediting(void), 158 | tty_islitecho(void), 159 | tty_isnewmap(void), 160 | tty_israw(void), 161 | tty_issofttab(void), 162 | tty_istrapsig(void), 163 | tty_linemode(void); 164 | 165 | extern void 166 | tty_rspeed(int), 167 | tty_setecho(int), 168 | tty_setedit(int), 169 | tty_setlinemode(int), 170 | tty_setlitecho(int), 171 | tty_setsig(int), 172 | tty_setsofttab(int), 173 | tty_tspeed(int), 174 | willoption(int), 175 | wontoption(int); 176 | 177 | int output_data(const char *, ...) __printflike(1, 2); 178 | void output_datalen(const char *, int); 179 | void startslave(char *, int, char *); 180 | 181 | #ifdef ENCRYPTION 182 | extern void (*encrypt_output)(unsigned char *, int); 183 | extern int (*decrypt_input)(int); 184 | extern char *nclearto; 185 | #endif /* ENCRYPTION */ 186 | 187 | 188 | /* 189 | * The following are some clocks used to decide how to interpret 190 | * the relationship between various variables. 191 | */ 192 | 193 | extern struct { 194 | int 195 | system, /* what the current time is */ 196 | echotoggle, /* last time user entered echo character */ 197 | modenegotiated, /* last time operating mode negotiated */ 198 | didnetreceive, /* last time we read data from network */ 199 | ttypesubopt, /* ttype subopt is received */ 200 | tspeedsubopt, /* tspeed subopt is received */ 201 | environsubopt, /* environ subopt is received */ 202 | oenvironsubopt, /* old environ subopt is received */ 203 | xdisplocsubopt, /* xdisploc subopt is received */ 204 | baseline, /* time started to do timed action */ 205 | gotDM; /* when did we last see a data mark */ 206 | } clocks; 207 | 208 | #ifndef DEFAULT_IM 209 | #ifdef __APPLE__ 210 | # define DEFAULT_IM "\r\n\r\nFreeBSD (%h) (%t)\r\n\r\r\n\r" 211 | #else 212 | # ifdef ultrix 213 | # define DEFAULT_IM "\r\n\r\nULTRIX (%h) (%t)\r\n\r\r\n\r" 214 | # else 215 | # ifdef __FreeBSD__ 216 | # define DEFAULT_IM "\r\n\r\nFreeBSD (%h) (%t)\r\n\r\r\n\r" 217 | # else 218 | # define DEFAULT_IM "\r\n\r\n4.4 BSD UNIX (%h) (%t)\r\n\r\r\n\r" 219 | # endif 220 | # endif 221 | #endif /* __APPLE__ */ 222 | #endif 223 | -------------------------------------------------------------------------------- /telnet/krb4-proto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights 7 | * Reserved. This file contains Original Code and/or Modifications of 8 | * Original Code as defined in and that are subject to the Apple Public 9 | * Source License Version 1.0 (the 'License'). You may not use this file 10 | * except in compliance with the License. Please obtain a copy of the 11 | * License at http://www.apple.com/publicsource and read it before using 12 | * this file. 13 | * 14 | * The Original Code and all software distributed under the License are 15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 19 | * License for the specific language governing rights and limitations 20 | * under the License." 21 | * 22 | * @APPLE_LICENSE_HEADER_END@ 23 | */ 24 | #ifdef __STDC__ 25 | # define P(s) s 26 | #else 27 | # define P(s) () 28 | #endif 29 | 30 | /* add_ticket.c */ 31 | int add_ticket P((KTEXT , int , char *, int , char *, char *, char *, int , KTEXT )); 32 | 33 | /* cr_err_reply.c */ 34 | void cr_err_reply P((KTEXT , char *, char *, char *, u_long , u_long , char *)); 35 | 36 | /* create_auth_reply.c */ 37 | KTEXT create_auth_reply P((char *, char *, char *, long , int , unsigned long , int , KTEXT )); 38 | 39 | /* create_ciph.c */ 40 | int create_ciph P((KTEXT , C_Block , char *, char *, char *, unsigned long , int , KTEXT , unsigned long , C_Block )); 41 | 42 | /* create_death_packet.c */ 43 | KTEXT krb_create_death_packet P((char *)); 44 | 45 | /* create_ticket.c */ 46 | int krb_create_ticket P((KTEXT , unsigned int , char *, char *, char *, long , char *, int , long , char *, char *, C_Block )); 47 | 48 | /* debug_decl.c */ 49 | 50 | /* decomp_ticket.c */ 51 | int decomp_ticket P((KTEXT , unsigned char *, char *, char *, char *, unsigned long *, C_Block , int *, unsigned long *, char *, char *, C_Block , Key_schedule )); 52 | 53 | /* dest_tkt.c */ 54 | int dest_tkt P((void )); 55 | 56 | /* extract_ticket.c */ 57 | int extract_ticket P((KTEXT , int , char *, int *, int *, char *, KTEXT )); 58 | 59 | /* fgetst.c */ 60 | int fgetst P((FILE *, char *, int )); 61 | 62 | /* get_ad_tkt.c */ 63 | int get_ad_tkt P((char *, char *, char *, int )); 64 | 65 | /* get_admhst.c */ 66 | int krb_get_admhst P((char *, char *, int )); 67 | 68 | /* get_cred.c */ 69 | int krb_get_cred P((char *, char *, char *, CREDENTIALS *)); 70 | 71 | /* get_in_tkt.c */ 72 | int krb_get_pw_in_tkt P((char *, char *, char *, char *, char *, int , char *)); 73 | int placebo_read_password P((des_cblock *, char *, int )); 74 | int placebo_read_pw_string P((char *, int , char *, int )); 75 | 76 | /* get_krbhst.c */ 77 | int krb_get_krbhst P((char *, char *, int )); 78 | 79 | /* get_krbrlm.c */ 80 | int krb_get_lrealm P((char *, int )); 81 | 82 | /* get_phost.c */ 83 | char *krb_get_phost P((char *)); 84 | 85 | /* get_pw_tkt.c */ 86 | int get_pw_tkt P((char *, char *, char *, char *)); 87 | 88 | /* get_request.c */ 89 | int get_request P((KTEXT , int , char **, char **)); 90 | 91 | /* get_svc_in_tkt.c */ 92 | int krb_get_svc_in_tkt P((char *, char *, char *, char *, char *, int , char *)); 93 | 94 | /* get_tf_fullname.c */ 95 | int krb_get_tf_fullname P((char *, char *, char *, char *)); 96 | 97 | /* get_tf_realm.c */ 98 | int krb_get_tf_realm P((char *, char *)); 99 | 100 | /* getopt.c */ 101 | int getopt P((int , char **, char *)); 102 | 103 | /* getrealm.c */ 104 | char *krb_realmofhost P((char *)); 105 | 106 | /* getst.c */ 107 | int getst P((int , char *, int )); 108 | 109 | /* in_tkt.c */ 110 | int in_tkt P((char *, char *)); 111 | 112 | /* k_gethostname.c */ 113 | int k_gethostname P((char *, int )); 114 | 115 | /* klog.c */ 116 | char *klog P((int , char *, int , int , int , int , int , int , int , int , int , int )); 117 | int kset_logfile P((char *)); 118 | 119 | /* kname_parse.c */ 120 | int kname_parse P((char *, char *, char *, char *)); 121 | int k_isname P((char *)); 122 | int k_isinst P((char *)); 123 | int k_isrealm P((char *)); 124 | 125 | /* kntoln.c */ 126 | int krb_kntoln P((AUTH_DAT *, char *)); 127 | 128 | /* krb_err_txt.c */ 129 | 130 | /* krb_get_in_tkt.c */ 131 | int krb_get_in_tkt P((char *, char *, char *, char *, char *, int , int (*key_proc )(), int (*decrypt_proc )(), char *)); 132 | 133 | /* kuserok.c */ 134 | int kuserok P((AUTH_DAT *, char *)); 135 | 136 | /* log.c */ 137 | void log P((char *, int , int , int , int , int , int , int , int , int , int )); 138 | int set_logfile P((char *)); 139 | int new_log P((long , char *)); 140 | 141 | /* mk_err.c */ 142 | long krb_mk_err P((u_char *, long , char *)); 143 | 144 | /* mk_priv.c */ 145 | long krb_mk_priv P((u_char *, u_char *, u_long , Key_schedule , C_Block , struct sockaddr_in *, struct sockaddr_in *)); 146 | 147 | /* mk_req.c */ 148 | int krb_mk_req P((KTEXT , char *, char *, char *, long )); 149 | int krb_set_lifetime P((int )); 150 | 151 | /* mk_safe.c */ 152 | long krb_mk_safe P((u_char *, u_char *, u_long , C_Block *, struct sockaddr_in *, struct sockaddr_in *)); 153 | 154 | /* month_sname.c */ 155 | char *month_sname P((int )); 156 | 157 | /* netread.c */ 158 | int krb_net_read P((int , char *, int )); 159 | 160 | /* netwrite.c */ 161 | int krb_net_write P((int , char *, int )); 162 | 163 | /* one.c */ 164 | 165 | /* pkt_cipher.c */ 166 | KTEXT pkt_cipher P((KTEXT )); 167 | 168 | /* pkt_clen.c */ 169 | int pkt_clen P((KTEXT )); 170 | 171 | /* rd_err.c */ 172 | int krb_rd_err P((u_char *, u_long , long *, MSG_DAT *)); 173 | 174 | /* rd_priv.c */ 175 | long krb_rd_priv P((u_char *, u_long , Key_schedule , C_Block , struct sockaddr_in *, struct sockaddr_in *, MSG_DAT *)); 176 | 177 | /* rd_req.c */ 178 | int krb_set_key P((char *, int )); 179 | int krb_rd_req P((KTEXT , char *, char *, long , AUTH_DAT *, char *)); 180 | 181 | /* rd_safe.c */ 182 | long krb_rd_safe P((u_char *, u_long , C_Block *, struct sockaddr_in *, struct sockaddr_in *, MSG_DAT *)); 183 | 184 | /* read_service_key.c */ 185 | int read_service_key P((char *, char *, char *, int , char *, char *)); 186 | 187 | /* recvauth.c */ 188 | int krb_recvauth P((long , int , KTEXT , char *, char *, struct sockaddr_in *, struct sockaddr_in *, AUTH_DAT *, char *, Key_schedule , char *)); 189 | 190 | /* save_credentials.c */ 191 | int save_credentials P((char *, char *, char *, C_Block , int , int , KTEXT , long )); 192 | 193 | /* send_to_kdc.c */ 194 | int send_to_kdc P((KTEXT , KTEXT , char *)); 195 | 196 | /* sendauth.c */ 197 | int krb_sendauth P((long , int , KTEXT , char *, char *, char *, u_long , MSG_DAT *, CREDENTIALS *, Key_schedule , struct sockaddr_in *, struct sockaddr_in *, char *)); 198 | int krb_sendsvc P((int , char *)); 199 | 200 | /* setenv.c */ 201 | int setenv P((char *, char *, int )); 202 | void unsetenv P((char *)); 203 | char *getenv P((char *)); 204 | char *_findenv P((char *, int *)); 205 | 206 | /* stime.c */ 207 | char *stime P((long *)); 208 | 209 | /* tf_shm.c */ 210 | int krb_shm_create P((char *)); 211 | int krb_is_diskless P((void )); 212 | int krb_shm_dest P((char *)); 213 | 214 | /* tf_util.c */ 215 | int tf_init P((char *, int )); 216 | int tf_get_pname P((char *)); 217 | int tf_get_pinst P((char *)); 218 | int tf_get_cred P((CREDENTIALS *)); 219 | int tf_close P((void )); 220 | int tf_save_cred P((char *, char *, char *, C_Block , int , int , KTEXT , long )); 221 | 222 | /* tkt_string.c */ 223 | char *tkt_string P((void )); 224 | void krb_set_tkt_string P((char *)); 225 | 226 | /* util.c */ 227 | int ad_print P((AUTH_DAT *)); 228 | int placebo_cblock_print P((des_cblock )); 229 | 230 | #undef P 231 | --------------------------------------------------------------------------------