Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

2 votes
2 answers
2270 views
How to create a socket forwarder as a server?
I'm looking for a tool that starts a socket server, and forwards incoming requests on that socket port to another internal one. I found `socat` is able to forward socket ports in general: socat tcp-l:8080,fork,reuseaddr tcp:127.0.0.1:12345 This forwards the "official" port `8080` to internal socket...
I'm looking for a tool that starts a socket server, and forwards incoming requests on that socket port to another internal one. I found socat is able to forward socket ports in general: socat tcp-l:8080,fork,reuseaddr tcp:127.0.0.1:12345 This forwards the "official" port 8080 to internal socket port 12345 successfully. BUT: my problem is that clients should be able to connect to port 8080 *even* if internal port 12345 is currently unavailable. The problem with socat is that it does not seem to create a real socket server, but justs remapps the port, and just puts the port on LISTENING. I'm looking for a tool that tells the client "You connected successfully, please send me your input". And if my local port 12345 is not available, the clients should get an error when trying to send data. So in case my local application is down, clients should still be able to establish a connection to that official ort. Is that possible without having to write my own tool?
membersound (490 rep)
Jul 8, 2019, 11:22 AM • Last activity: Aug 6, 2025, 07:06 AM
0 votes
1 answers
2087 views
Selinux php-fpm httpd and mariadb socket connection
*New note with important details* I just ran a few version tests and resulted in the following: Alright, here’s my latest update: - 10.5 works - 10.6 doesn’t - 10.7 works - 10.8 work - etc. I was hoping to use 10.6 since it is the LTS release…clearly there is something wrong with it though. I’m on t...
*New note with important details* I just ran a few version tests and resulted in the following: Alright, here’s my latest update: - 10.5 works - 10.6 doesn’t - 10.7 works - 10.8 work - etc. I was hoping to use 10.6 since it is the LTS release…clearly there is something wrong with it though. I’m on the MariaDB slack channel at the moment, but for now I’ll revert to 10.5 from the MariaDB repo, since that has support for 2 years-ish. Am I missing something else? I didn't change anything but the MariaDB version and restarting the process. *Edit note for reference* Installing the EL Repo MariaDB 10.5 installs a package "mysql-selinux" and the default repo (epel-release?) allows the necessary communications and php-fpm can connect to mariadb fine. It seems like maybe the MariaDB repo package is missing this functionality. I would have installed the EL repo MariaDB on my AL 8.6 system, but removed it and went with the MariaDB repo for regular operation. I found the source for "mysql-selinux" here and it's not trivial like my "fix": https://github.com/devexp-db/mysql-selinux/blob/master/mysql.te this package is NOT installed on my 8.6 system which works... ***** I have a system running fine with SELinux enabled on AlmaLinux 8.6. I'm using stock AL 8.6 Apache/httpd (2.4.37 I think) and php from Remi's Repo: https://rpms.remirepo.net/wizard/ I initially installed MariaDB 10.4 directly from the MariaDB repo using these instructions: https://mariadb.com/resources/blog/how-to-install-mariadb-on-rhel8-centos8/ SELinux is enabled and I don't believe I made any customizations specifically for php-fpm to connect to the mysql.sock socket/process. I recently upgraded to MariaDB 10.6, again from the MariaDB repo, and everything continued working as it always did. For reference my "working" validation is using phpMyAdmin configured to connect through a local socket. I've installed my AlmaLinux 9 VM with stock Apache/httpd (2.4.51 I think). I installed MariaDB 10.6 from the same repo with the same instructions. Now, I'm getting a denial from SELinux for php-fpm (running as httpd_t) trying to connect to the /var/lib/mysql/mysql.sock process (running as unconfinsed_service_t). This denial prevents the connection and subsequent login from phpMyAdmin (running under the php-fpm service):
time->Mon Sep 26 22:14:07 2022
type=PROCTITLE msg=audit(1664244847.002:83): proctitle=7068702D66706D3A20706F6F6C20777777
type=SYSCALL msg=audit(1664244847.002:83): arch=c000003e syscall=42 success=no exit=-13 a0=5 a1=7ffc156c46b0 a2=1b a3=557032b785a0 items=0 ppid=706 pid=738 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="php-fpm" exe="/opt/remi/php74/root/usr/sbin/php-fpm" subj=system_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1664244847.002:83): avc:  denied  { connectto } for  pid=738 comm="php-fpm" path="/var/lib/mysql/mysql.sock" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:unconfined_service_t:s0 tclass=unix_stream_socket permissive=0
This ONLY shows up on my AL 9 install, AL 8.6 does not report this denial and allows the connection and subsequent login. I checked the file and process SELinux contexts and they are the same between 8.6 and 9. I've also tried different php-fpm versions, including the same between my 8.6 install and 9 (both php 7.4 from Remi). I've tried running the fpm pool under apache:apache and under my phpMyAdmin user with group apache. Any advice on how to track this down? I can "fix" the SELinux denial with the following policy, but it allows httpd to connect to any unconfined process:
module phpfpm_mariadb_socket 1.0;

require {
        type httpd_t;
        type unconfined_service_t;
        class unix_stream_socket connectto;
}

#============= httpd_t ==============
allow httpd_t unconfined_service_t:unix_stream_socket connectto;
I see two obvious differences: Apache 2.4.37 vs 2.4.51 (and potential related SELinux policy changes which I couldn't track down) and EL 8.6 vs EL 9 SELinux core changes (both had "latest" available updates applied). I copied the phpMyAdmin install from my 8.6 system into my 9 system, under the same usernames with the same permissions. I don't think that the php-fpm user:group configuration is relevant to the process contexts, or is it?
Brian (292 rep)
Sep 27, 2022, 11:42 AM • Last activity: Jul 23, 2025, 05:03 PM
2 votes
1 answers
207 views
TCP checksum offloading on virtio-net paravirtualized interfaces
Consider the topology where 2 QEMU VMs running Linux Ubuntu `16.04` kernel version `4.4.0-210` have both `virtio-net` interfaces with `TAP` backends connected to the same (host) Linux `bridge` and an `SSH` connection between them. ubuntu@VM1:~$ uname -a Linux VM1 4.4.0-210-generic #242-Ubuntu SMP Fr...
Consider the topology where 2 QEMU VMs running Linux Ubuntu 16.04 kernel version 4.4.0-210 have both virtio-net interfaces with TAP backends connected to the same (host) Linux bridge and an SSH connection between them. ubuntu@VM1:~$ uname -a Linux VM1 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 x86_64 x8x ubuntu@VM1:~$ Both VMs use paravirtualized virtio-net interfaces defaulting to TX and RX checksum offloading. ubuntu@VM1:~$ ethtool -i eth0 driver: virtio_net version: 1.0.0 firmware-version: expansion-rom-version: bus-info: 0000:00:03.0 supports-statistics: no supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no ubuntu@VM1:~$ ubuntu@VM1:~$ ethtool -k eth0 | grep -i sum rx-checksumming: on [fixed] tx-checksumming: on tx-checksum-ipv4: off [fixed] tx-checksum-ip-generic: on tx-checksum-ipv6: off [fixed] tx-checksum-fcoe-crc: off [fixed] tx-checksum-sctp: off [fixed] ubuntu@VM1:~$ ubuntu@VM2:~$ ethtool -k eth0 | grep -i sum rx-checksumming: on [fixed] tx-checksumming: on tx-checksum-ipv4: off [fixed] tx-checksum-ip-generic: on tx-checksum-ipv6: off [fixed] tx-checksum-fcoe-crc: off [fixed] tx-checksum-sctp: off [fixed] ubuntu@VM2:~$ That actually means: - kernel network stack sends out SSH/TCP packets without computing & filling the relevant TCP checksum field inside them (i.e. basically the TCP checksum inside the packets sent is either zeroed out or incorrect) - kernel network stack assumes the virtio-net interface has already checked/verified the TCP checksum for SSH/TCP received packets and is therefore allowed to skip it Hence the SSH connection works even though traveling SSH/TCP packets have an *incorrect* TCP checksum (tcpdump run inside both VM confirms this). Later, changing the topology by connecting each VM to a different linux bridge with a virtual router in the middle, suddenly the SSH connection stop working. I double checked that virtual router actually forwards TCP/SSH packets *as-is* from a bridge to the the other (in both directions), so I don't understand why the SSH connection stopped working this time. What is going on in the latter case ? Thanks.
CarloC (385 rep)
Jul 7, 2025, 05:59 AM • Last activity: Jul 7, 2025, 09:09 AM
1 votes
1 answers
1886 views
How does bind(2) choose a network device?
**Background** I'm looking to write kernel-space implementations of a non-IP network protocol and associated network device driver (non-ethernet hardware). I found some resources on developing the protocol and the driver, though I'm having difficulty understanding how to associate sockets using my p...
**Background** I'm looking to write kernel-space implementations of a non-IP network protocol and associated network device driver (non-ethernet hardware). I found some resources on developing the protocol and the driver, though I'm having difficulty understanding how to associate sockets using my protocol with my driver. The aim is to have it working such that a program in userspace would only need to call bind(socket(AF_TERRIBLE_IDEA, ...), ...); and be good to go. The aim is to get more familiar developing for kernel-space simultaneously, so moving to userspace is not ideal. **Question** when a *bind* call is made, how does the kernel know which device (and therefore device driver) to associate a socket to?
Kenneth Hau (21 rep)
Sep 23, 2018, 01:32 AM • Last activity: Jul 4, 2025, 09:00 AM
0 votes
1 answers
44 views
Getting ancillary data of a packet after recv() call
Is there a way to get ```struct msghdr``` or ancillary data of it for the last received packet, *i.e.* after the recv() call? My guess is that ```recvmsg()``` is the only way to populate ```msghdr```, but probably there is a hack on how to get ancillary data independently of ```recv```.
Is there a way to get
msghdr
or ancillary data of it for the last received packet, *i.e.* after the recv() call? My guess is that
()
is the only way to populate
, but probably there is a hack on how to get ancillary data independently of
.
Alex (1 rep)
Jun 27, 2025, 10:33 AM • Last activity: Jun 27, 2025, 11:07 AM
2 votes
1 answers
140 views
socat pty,echo=0 terminal option does not work
I'd use `socat` to redirect the `STDIN/STDOUT` of the process executing `docker run -it ubuntu bash` command to a `tcp` socket in listening on port `32000`. root@eve-ng:~# socat -d -d -d EXEC:'docker run -it ubuntu bash',pty,echo=0 TCP4-LISTEN:32000 From another terminal root@eve-ng:~# nc -v 127.0.0...
I'd use socat to redirect the STDIN/STDOUT of the process executing docker run -it ubuntu bash command to a tcp socket in listening on port 32000. root@eve-ng:~# socat -d -d -d EXEC:'docker run -it ubuntu bash',pty,echo=0 TCP4-LISTEN:32000 From another terminal root@eve-ng:~# nc -v 127.0.0.1 32000 Connection to 127.0.0.1 32000 port [tcp/*] succeeded! root@ada2551fd122:/# ls /usr ls /usr bin games include lib lib64 libexec local sbin share src root@ada2551fd122:/# As you can see, the connection takes place and the command ls /usr executed within the container. The problem I'm facing to is that ls /usr like any other command entered is echoed back *twice*. As far as I can tell, the option echo=0 is there to prevent this behavior, however it doesn't seem to work as expected. What is actually going on ? Thanks.
CarloC (385 rep)
Jun 23, 2025, 05:53 AM • Last activity: Jun 23, 2025, 07:20 AM
1 votes
0 answers
87 views
Using socat to redirect docker attach's STDIN/STDOUT to a TCP socket
I'd like to use `socat` to redirect the `STDIN/STDOUT` of the process executing `docker attach ` to a listening `TCP` socket on my Linux system. root@eve-ng:/opt/unetlab# tty /dev/pts/2 root@eve-ng:/opt/unetlab# root@eve-ng:/opt/unetlab# socat EXEC:'/usr/bin/docker attach afe29573-0030-4a69-8b3e-c04...
I'd like to use socat to redirect the STDIN/STDOUT of the process executing docker attach to a listening TCP socket on my Linux system. root@eve-ng:/opt/unetlab# tty /dev/pts/2 root@eve-ng:/opt/unetlab# root@eve-ng:/opt/unetlab# socat EXEC:'/usr/bin/docker attach afe29573-0030-4a69-8b3e-c04ededa8db7-0-4',pty TCP4-LISTEN:32000 & 1275378 root@eve-ng:/opt/unetlab# The options for socat are the following: - EXEC:,pty to say socat to start a process executing ` allocating a pseudo-terminal pty attached to its STDIN/STDOUT (socat actually opens the master side multiplexer /dev/ptmx and then the fd for the pseudo-terminal pair's master ptm`) - TCP4-LISTEN:32000 to say socat to open a tcp socket listening on port 32000 Indeed, in another terminal you can check: root@eve-ng:~# tty /dev/pts/5 root@eve-ng:~# root@eve-ng:~# ps -ef | grep attach root 1275378 1210230 0 08:43 pts/2 00:00:00 socat EXEC:/usr/bin/docker attach afe29573-0030-4a69-8b3e-c04ededa8db7-0-4,pty TCP4-LISTEN:32000 root 1275379 1275378 0 08:43 pts/2 00:00:00 /usr/bin/docker attach afe29573-0030-4a69-8b3e-c04ededa8db7-0-4 root@eve-ng:~# docker attach actually attaches to a process running inside the container executing the exec executable, by the way you can see pts/1 is allocated to it (the container indeed was created using docker create -it) root@eve-ng:~# ps -ef | grep exec root 1284441 731051 2 08:52 pts/1 00:00:00 exec root 1284583 1222614 0 08:53 pts/5 00:00:00 grep --color=auto exec root@eve-ng:~# The problem I'm facing to is that connecting to the tcp socket 127.0.0.1:32000 from a telnet client, the login process inside the container (exec) doesn't work as expected. It seems the username typed in (carlo) is repeated again not allowing to successfully login into the container. Username: carlo carlo Password: RP/0/RP0/CPU0:Jun 20 09:00:59.739 UTC: exec: %SECURITY-LOGIN-4-AUTHEN_FAILED : Failed authentication attempt by user '' from 'console' on 'con0_RP0_CPU0' User Access Verification Username: Can you help me in understanding why ? Thanks. P.s. digging into it using strace I noticed that socat actually reads from the relevant fd (of type tcp socket) twice instead of just once.
CarloC (385 rep)
Jun 20, 2025, 09:05 AM • Last activity: Jun 22, 2025, 07:17 PM
0 votes
0 answers
34 views
Why does Ctrl+C clear the current input line in my Python socket-based Telnet-like shell?
I'm building a simple shell server using raw Python sockets (not using telnetlib). The client connects using PuTTY with the Telnet connection type. The server displays a basic prompt like: [user@hostname:~]# --- ## The issue: ## When I type a command (for example, wh0ami) and press Ctrl+C, the entir...
I'm building a simple shell server using raw Python sockets (not using telnetlib). The client connects using PuTTY with the Telnet connection type. The server displays a basic prompt like: [user@hostname:~]# --- ## The issue: ## When I type a command (for example, wh0ami) and press Ctrl+C, the entire line is wiped and only a fresh prompt appears: [user@hostname:~]# wh0ami ← typed input ^C ← pressed Ctrl+C [user@hostname:~]# ← result: input line cleared --- ## What I expect: ## In typical terminal behavior (like Bash or real Telnet servers), I would expect to see something like: [user@hostname:~]# wh0ami^C [user@hostname:~]# But in my case, the previously typed input disappears completely after pressing Ctrl+C. --- ## Notes: ## - I’m not using raw terminal mode — and I’m unable to use it for my use case. --- ## Question: ## Why does Ctrl+C cause the current input line to be cleared in this setup? Is this normal Telnet behavior, or am I missing something related to how the input buffer or terminal display should be handled? What's the solution to this? Thanks in advance. ---
just.callme.client (51 rep)
Jun 17, 2025, 07:39 AM
0 votes
0 answers
21 views
Issue in l2cap test - Bluez
I'm currently testing the bluez tools like l2ping & l2test, So my intention was to interface between two devices through l2cap layer. I have cloned the bluez repository on two raspberry pi devices, and made necessary configuration to execute those tools, but I didn't get the expected output instead...
I'm currently testing the bluez tools like l2ping & l2test, So my intention was to interface between two devices through l2cap layer. I have cloned the bluez repository on two raspberry pi devices, and made necessary configuration to execute those tools, but I didn't get the expected output instead the program stuck at socket level during connect stage on sender due to which the receiver waits on accept stage, this result in either Host is down or Connection Refused Error, also I tried this sample tools on two different systems(PC) got the similar results, can someone guide me on what I'm missing here.
$  sudo ./tools/l2test -p  C5:86:1A:53:D7:3B
Can't connect socket: Host is down
Server
Advertisment start success

*** Booting Zephyr OS build v4.1.0-1545-gfa45bebccfb1 ***
[00:00:00.255,462]  bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:00.255,493]  bt_hci_core: HW Variant: nRF52x (0x0002)
[00:00:00.255,523]  bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 4.1 Build 99
[00:00:00.256,561]  bt_hci_core: Identity: C5:86:1A:53:D7:3B (random)
[00:00:00.256,591]  bt_hci_core: HCI: version 5.4 (0x0d) revision 0x0000, manufacturer 0x05f1
[00:00:00.256,622]  bt_hci_core: LMP: version 5.4 (0x0d) subver 0xffff
Here, I made a NRF device as peripheral which is discoverable & connectable, it advertises its info, using which it can be connected, this device can be connected using bluetoothctl but couldn't be connected using l2test Two Raspberry Pis running BlueZ. My goal is to establish an L2CAP channel using tools like l2test and l2ping. The peripheral device (nRF52) successfully advertises and can be connected via bluetoothctl, but any attempt to connect using l2test fails with errors like Host is down or Connection refused. I've also replicated the test between two Raspberry Pi devices with the same result: the server waits on a PSM, but the client fails to connect. I'm trying to understand if this is a configuration issue, a limitation of the tools, or if additional setup (e.g., registering a PSM for LE CoC) is needed. I'd appreciate guidance on what's missing or how to properly use L2CAP over BLE with BlueZ and Zephyr. 2nd Approach using two PI devices
pi@raspberrypi:~/bluez $ sudo ./tools/l2test -V le_public -r
l2test: Waiting for connection on psm 128 ...
pi@raspberrypiclient:~/bluez $ sudo ./tools/l2test -V le_public -s DC:A6:32:76:10:DA                                                                      
l2test: Can't connect: Connection refused (111)
Sandy (1 rep)
Jun 16, 2025, 01:35 PM
0 votes
1 answers
69 views
Configure mpd to only start a UNIX socket
Running `mpd` without any `bind_to_address` in the config starts a working UNIX socket at `/run/user/1000/mpd/socket` but also starts a network socket at `0.0.0.0:6600` / `[::]:6600`. I would like to have only the UNIX socket without any network sockets, however, when configuring `bind_to_address "/...
Running mpd without any bind_to_address in the config starts a working UNIX socket at /run/user/1000/mpd/socket but also starts a network socket at 0.0.0.0:6600 / [::]:6600. I would like to have only the UNIX socket without any network sockets, however, when configuring bind_to_address "/run/user/1000/mpd/socket" it only works if the socket directory is already created (e.g. by starting mpd without any bind_to_address previously). This means it fails after reboot. Also, this method would hardcode the socket address instead of using $XDG_RUNTIME_DIR. Is there a way to make mpd start only a UNIX socket (and ideally read $XDG_RUNTIME_DIR for that) using plain mpd without systemd?
niklassc (113 rep)
May 23, 2025, 01:18 AM • Last activity: May 28, 2025, 04:47 AM
0 votes
0 answers
62 views
/dev/log is a socket not a symbolic link
I am trying to understand why one of my system has /dev/log as a socket and other has /dev/log as a symbolic link. [ec2-user@ip-171-31-12-17 log]$ file /dev/log /dev/log: symbolic link to /run/systemd/journal/dev-log [ec2-user@ip-171-31-12-18 log]$ file /dev/log /dev/log: socket I have tried checkin...
I am trying to understand why one of my system has /dev/log as a socket and other has /dev/log as a symbolic link. [ec2-user@ip-171-31-12-17 log]$ file /dev/log /dev/log: symbolic link to /run/systemd/journal/dev-log [ec2-user@ip-171-31-12-18 log]$ file /dev/log /dev/log: socket I have tried checking on other systems and found out most of the RHEL has /dev/log as link not a socket. That means I have to make the other systems /dev/log as a link not socket. Does journalctl logs appear in /var/log/messages ? when i have /dev/log as socket instead of link. How do I make things normal ? By the way OS version is RHEL 7.9 for /dev/log : socket
Boogeyman (1 rep)
May 25, 2025, 06:57 AM
1 votes
2 answers
2507 views
Linux nuisance: /dev/stdin doesn't work with sockets
Linux has this blitheringly annoying peculiarity that `/dev/stdin` won't work with sockets - it is hardcoded to return ENXIO. Try this: socat TCP-OPEN:localhost:1234 EXEC:cat\ /dev/stdin,nofork That's a perfectly reasonable command you'd expect to work, and does on basically every system, except Lin...
Linux has this blitheringly annoying peculiarity that /dev/stdin won't work with sockets - it is hardcoded to return ENXIO. Try this: socat TCP-OPEN:localhost:1234 EXEC:cat\ /dev/stdin,nofork That's a perfectly reasonable command you'd expect to work, and does on basically every system, except Linux. (I'm using cat as a general example of any tool that opens a filename as the only way for you to specify a specific fd to use.) The linux kernel is explicitly written to forbid sensible use of /dev/stdin in this way ­— see http://marc.info/?l=ast-users&m=120978595414993 . If you only need unidirectional capability, you can buffer the data in a separate process: socat TCP-OPEN:localhost:1234 SYSTEM:'cat | thingy /dev/stdin' It's wasteful, and worse, is useless if thingy is meant to be reading and writing to the same fd, because pipes are unidirectional in Linux. What are we meant to do? /dev/stdin simply can't be used on Linux for building pipelines with bidirectional pipes, as far as I can tell, because sockets are the only underlying mechanism on Linux that yield a bidi stream with a single fd to read and write from (unlike a pair of pipes).
Nicholas Wilson (1088 rep)
Nov 5, 2013, 03:38 PM • Last activity: May 21, 2025, 04:27 PM
7 votes
2 answers
19190 views
What's the difference between ">&1" and ">/proc/self/fd/1" redirection?
I'm working on some script that being run by `rc.local` at startup, and I noticed that output redirection works quite strange. If I write something like `echo "foo" >&1`, it ends up in syslog, and all is okay. But when I write `echo "foo" >>/dev/stdout`, or `echo "foo" >>/proc/self/fd/1`, I got an e...
I'm working on some script that being run by rc.local at startup, and I noticed that output redirection works quite strange. If I write something like echo "foo" >&1, it ends up in syslog, and all is okay. But when I write echo "foo" >>/dev/stdout, or echo "foo" >>/proc/self/fd/1, I got an error saying that there is no such device or address. Further investigation revealed that /proc/self/fd/1 was in fact a socket. Including ls -l /proc/self/fd in rc.local prints the following: lr-x------. 1 root root 64 Jul 14 05:28 0 -> /dev/null lrwx------. 1 root root 64 Jul 14 05:28 1 -> socket: lrwx------. 1 root root 64 Jul 14 05:28 2 -> socket: lr-x------. 1 root root 64 Jul 14 05:28 255 -> /etc/rc.d/rc.local ---------- The described behaviour can be easily reproduced with nc. First, find out which file descriptor binds to socket. You can do it by issuing nc -l -p 25566 -c "ls -l /proc/self/fd" in first terminal and then telnet localhost 25566 in other terminal. In my case it was 5-th descriptor. Okay. Then, to reproduce the issue, in first terminal: nc -l -p 25566 -c "echo 'hello' >&5" in second terminal: telnet localhost 25566 You shall see "hello" in second terminal output between telnet messages about connection being established and closed. Now the case with file descriptor pseudo-file from /proc: first terminal: nc -l -p 25566 -c "echo 'hello' >/proc/self/fd/5" second terminal: telnet localhost 25566 Now second terminal just contains telnet messages about connection established and immediately closed, and first terminal shows an error: sh: /proc/self/fd/5: No such device or address. **Edit:** OS is Fedora 23 i686 server ---------- So, the question. What's the difference between >&1 and >/proc/self/fd/1 ? And is there some universal and reliable way to redirect output to some file, which corresponds exactly to current standard output? Thank you. ---------- **Edit 2:** For clarity, exact input/output for Fedora 23 i686 for above case: Terminal 1 | Terminal 2 $ nc -l -p 25566 -c 'ls -go /proc/self/fd' | | $ telnet localhost 25566 | Trying ::1... | Connected to localhost. | Escape character is '^]'. | total 0 | lr-x------ 1 64 Jul 14 08:56 0 -> pipe: | l-wx------ 1 64 Jul 14 08:56 1 -> pipe: | lrwx------ 1 64 Jul 14 08:56 2 -> /dev/tty2 | lr-x------ 1 64 Jul 14 08:56 3 -> pipe: | lr-x------ 1 64 Jul 14 08:56 4 -> /proc/1285/fd | lrwx------ 1 64 Jul 14 08:56 5 -> socket: | l-wx------ 1 64 Jul 14 08:56 7 -> /pipe: | Connection closed by foreign host. $ nc -l -p 25566 -c "echo 'hi' >&5" | | $ telnet localhost 25566 | Trying ::1... | Connected to localhost. | Escape character is '^]'. | hi | Connection closed by foreign host. $ nc -l -p 25566 -c "echo 'hi' >/proc/self/fd/5" | | $ telnet localhost 25566 | Trying ::1... | Connected to localhost. sh: /proc/self/fd/5: No such device or address | Escape character is '^]'. | Connection closed by foreign host. $ | $
alexey.e.egorov (333 rep)
Jul 14, 2016, 02:18 PM • Last activity: May 20, 2025, 03:52 AM
8 votes
2 answers
3405 views
Using a Unix Domain Socket to Control VLC
I am interested in using a UNIX-Domain Socket to control VLC playback. This functionality is outlined in the [VideoLan documentation for using oldrc][1]. So what I need to is startup vlc with a command such as: cvlc -I oldrc --rc-unix /some/socket And then I should be able to send vlc commands to `/...
I am interested in using a UNIX-Domain Socket to control VLC playback. This functionality is outlined in the VideoLan documentation for using oldrc . So what I need to is startup vlc with a command such as: cvlc -I oldrc --rc-unix /some/socket And then I should be able to send vlc commands to /some/socket to control the playback. Are there any general-purpose sockets floating around somewhere on my Kubuntu 12.10 system that I could use for this?
Lombard (203 rep)
Jan 19, 2014, 01:50 AM • Last activity: May 4, 2025, 10:51 AM
0 votes
2 answers
1957 views
Mariadb on Raspbian: Can't connect to local MySQL server through socket
I'm setting up a "clean" image for my home Raspberry pi running the latest Raspbian, and I'm finding a small problem when installing the mariadb database. So far, the steps I've taken are the following: ```` sudo apt-get install -y mariadb-server sudo nano /etc/mysql/my.cnf ```` Add the following li...
I'm setting up a "clean" image for my home Raspberry pi running the latest Raspbian, and I'm finding a small problem when installing the mariadb database. So far, the steps I've taken are the following:
`
  sudo apt-get install -y mariadb-server

  sudo nano /etc/mysql/my.cnf
` Add the following lines to my.cnf:
`
  [mysqld]
  datadir=/mnt/RaspberryData/mysql
  socket=/mnt/RaspberryData/mysql/mysql.sock
  [client]
  port=3306
  socket=/mnt/RaspberryData/mysql/mysql.sock
` The path /mnt/RaspberryData/mysqlcontains the database info of my previous installation, which was configured through a hard link. This may or may not be the issue. Then execute:
`
  sudo sytemctl start mariadb
  journalctl -u mariadb
` And here's when I have the issue:
`
Jun 22 19:18:33 raspberrypi systemd: Starting MariaDB 10.3.22 database server...
Jun 22 19:18:34 raspberrypi mysqld: 2020-06-22 19:18:34 0 [Note] /usr/sbin/mysqld (mysqld 10.3.22-MariaDB-0+deb10u1) starting as process 2623 ...
Jun 22 19:18:35 raspberrypi systemd: Started MariaDB 10.3.22 database server.
Jun 22 19:18:35 raspberrypi /etc/mysql/debian-start: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
Jun 22 19:18:35 raspberrypi /etc/mysql/debian-start: Looking for 'mysql' as: /usr/bin/mysql
Jun 22 19:18:35 raspberrypi /etc/mysql/debian-start: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Jun 22 19:18:35 raspberrypi /etc/mysql/debian-start: Version check failed. Got the following error when calling the 'mysql' command line client
Jun 22 19:18:35 raspberrypi /etc/mysql/debian-start: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Jun 22 19:18:35 raspberrypi /etc/mysql/debian-start: FATAL ERROR: Upgrade failed
` As you can see, there's some kind of update process that is trying to connect through a socket located in /var/run/mysqld/mysqld.sockbut that path has nothing (Only a mysqld.pid file). I'm guessing the guides on how to move the data from one location to another omitted some process or whatnot, as I can actually get into the database and execute queries. So, what am I missing here?
Neuromante (131 rep)
Jun 22, 2020, 06:56 PM • Last activity: Apr 18, 2025, 12:01 PM
7 votes
2 answers
1147 views
ICMP echo traffic doesn't NEED to be operated on a raw socket any more than UDP or TCP traffic does, so why is it done that way?
If you've ever tried writing tools that depend upon ICMP echo requests, you've inevitably run into the same problem as everyone else: you can't do it unless your tool is running as root. When you try to find out why this is the case, the answer is always the same: "sending icmp traffic requires the...
If you've ever tried writing tools that depend upon ICMP echo requests, you've inevitably run into the same problem as everyone else: you can't do it unless your tool is running as root. When you try to find out why this is the case, the answer is always the same: "sending icmp traffic requires the privileges to open a raw socket, so you must have root privileges to send ICMP traffic." While this is technically true, and at least advises the engineer writing the tool of their options, it fails to answer the underlying question of why ICMP traffic is somehow so special that there is no facility whatsoever for sending and receiving it as an unprivileged user. UDP and TCP are both considerably more complex than an ICMP echo request, but UDP and TCP have both been exposed to the user without giving them the full power of reading and writing to the network with reckless abandon. What is it that actually prevents a library from providing unprivileged ability to send and receive pings with no more control over the contents than icmp sequence, packet contents (or even just the size) id, ttl, and MAYBE tos? I'm not looking for an engineering workaround here, because one does not exist for the general purpose. I've seen advice to just make a system call to /usr/bin/ping but that's not really suitable either. The question comes down to this: is there some potential situation where having a general-purpose ICMP echo library would lead to users either conflicting with each other or somehow provide a level of power to the user that is dangerous? The latter scenario seems ludicrous to me just based on the fact that an echo request is actually less configurable than a UDP datagram. I'd use UDP if it would serve the functions I need, but it absolutely does not.
Sniggerfardimungus (326 rep)
Mar 2, 2025, 09:43 PM • Last activity: Mar 9, 2025, 02:56 AM
1 votes
1 answers
163 views
Ham Radio simulator: live streaming microphone audio between 2 browsers, connected via ubuntu 22
I am trying to simulate a radio with a PTT button. Connected users should be able to live voice chat in the group, one at a time, while holding a button. I have a Ubuntu 22.04 server running, with nginx, but unfortunately nothing seems to work. I don't know exactly what a good method should be. I tr...
I am trying to simulate a radio with a PTT button. Connected users should be able to live voice chat in the group, one at a time, while holding a button. I have a Ubuntu 22.04 server running, with nginx, but unfortunately nothing seems to work. I don't know exactly what a good method should be. I tried using sockets but i keep getting console errors (on Firefox) like: Media resource blob:https://mywebsite could not be decoded, error: Error Code: NS_ERROR_DOM_MEDIA_METADATA_ERR (0x806e0006) How exactly would a live audio browser transmission protocol look like? async function startTransmission() { if (!mediaStream) { try { mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true }); mediaRecorder = new MediaRecorder(mediaStream, { mimeType: "audio/webm;codecs=opus" }); mediaRecorder.ondataavailable = (event) => { if (event.data.size > 0) { socket.emit("audio-stream", event.data); } }; mediaRecorder.start(300); // Send audio in 300ms chunks logMessage("🔊 Transmitting Audio..."); } catch (error) { console.error("Microphone access denied:", error); logMessage("⚠️ Microphone access denied."); } }} and server: socket.on("audio-stream", (audioData) => { io.emit("receive-audio", { audioData, mimeType: "audio/webm;codecs=opus", senderId: socket.id // Send the sender's ID so they can ignore their own audio });});
George Stefan Kudor-Ghitescu (11 rep)
Feb 22, 2025, 04:24 AM • Last activity: Feb 25, 2025, 11:28 AM
0 votes
0 answers
128 views
Postfix/Dovecot configuration to gmail as relay
Does any one have a complete configuration of using Dovecot to handle OAuth2 tokens to allow Postfix to send mail to gmail? Most use cases found are either too old or not complete. I have done the required steps from the google api and received a credential in json format. Thanks in advance, Dean
Does any one have a complete configuration of using Dovecot to handle OAuth2 tokens to allow Postfix to send mail to gmail? Most use cases found are either too old or not complete. I have done the required steps from the google api and received a credential in json format. Thanks in advance, Dean
Dean Allard (1 rep)
Jan 31, 2025, 09:00 PM
10 votes
5 answers
1205 views
How to check multiple hosts for simple connectivity?
I need a tool that tells me if a connection to a host is open or not -- no data to send or receive, just see if the connection is successful. Today I use telnet. $ telnet myhost myport Trying 192.168.1.99... Connected to myhost. Escape character is '^]'. ^[^] telnet> quit Connection closed. ... but...
I need a tool that tells me if a connection to a host is open or not -- no data to send or receive, just see if the connection is successful. Today I use telnet. $ telnet myhost myport Trying 192.168.1.99... Connected to myhost. Escape character is '^]'. ^[^] telnet> quit Connection closed. ... but I need to have manual input there: the ^] and then also the quit. I need to check several hosts, and that's too much for my simple method. How can I do check for connectivity to multiple hosts more effectively? I would prefer to use a pre-existing tool.
chris01 (869 rep)
Dec 12, 2024, 04:43 PM • Last activity: Jan 17, 2025, 12:15 PM
2 votes
1 answers
2273 views
Find the creator of a particular Unix socket
I'm struggling to find out which process exactly created a Unix socket. I've read couple posts about it like using `lsof -nl` (which generally gets the pid of a process which listens to Unix socket), using `netstat -tulpen` which doesn't show the socket I'm searching for and etc. Basically what I wa...
I'm struggling to find out which process exactly created a Unix socket. I've read couple posts about it like using lsof -nl (which generally gets the pid of a process which listens to Unix socket), using netstat -tulpen which doesn't show the socket I'm searching for and etc. Basically what I want is that gnome-keyring process listens to some unix socket (/run/user/1000/keyring-.../ssh) but which process exactly created that socket? Is there any command that would help me to find which process exactly (I could use Unix socket name if that would be helpful) created a socket? thanks. **P.S** Should not that information be held somewhere in /proc/pid/...?
Ojs (121 rep)
Feb 6, 2018, 03:00 PM • Last activity: Jan 16, 2025, 06:04 PM
Showing page 1 of 20 total questions