• 0 Posts
  • 139 Comments
Joined 2 years ago
cake
Cake day: June 5th, 2023

help-circle
  • Yeah no problem. I’d like to point out that this puts a hole in your firewall. If you have something exposed via udp, and an attacker knows about your --sport rule or figures this out, they can connect to it just by setting their source port to 5353. You can check what’s listening on udp with ss -lun or sudo ss -lunp (for process info).

    Also, I have looked up what @Eideen@lemmy.world said about dig not supporting mdns and I think they are correct. With mdns, because of the multicast nature, you can get replies from multiple computers, and that’s a pretty big difference to regular dns. How could it even reliably know it has gotten all the replies or if it should wait for more? It just sort of happens to work correctly if you get a single reply.

    Also, and I also looked this up, mdns lookups will to go through avahi-daemon on regular glibc distros. The libnss-mdns plugin description for glibc says this:

    nss-mdns tries to contact a running avahi-daemon for resolving host names and addresses and making use of its superior record cacheing. If Avahi is not available at lookup time, the lookups will fail.


  • As I said, I’m not sure about that.

    Still, dig won’t be listening on port 5353 for the answer, it’ll open some random port, so the firewall rule for 5353 will not apply. And the conntrack rule, is my guess, also doesn’t apply, because what I think the conntrack module does is:

    • Remembers about the outgoing connection (i.e. when dig sends its udp packet out): source port, destination IP and port
    • Check incoming packets against this info, and lets them through if they appear to be an answer

    Since the outgoing packet is going to multicast, and the incoming packet (I suspect) is coming from the IP of the machine that answers (a different IP therefore), conntrack wouldn’t be able to figure that out. The answer doesn’t match the outgoing packet that dig sends. Since this is just a hunch, I would try to confirm this by looking at the traffic in e.g. wireshark.


  • My hunch on what’s going on: Dig opens up a different udp port (it has to, there would be avahi-daemon listening on 5353). So it sends out to the multicast address on 5353, but the answer comes back from the actual IP of whoever is answering, to whatever port dig is listening on, and the connection tracking is not smart enough to figure out this should be let through?

    You should look at the traffic with wireshark.

    Also maybe that’s fine in practice? Do applications actually run their own mDNS queries? Maybe it all goes through avahi-daemon? That uses port 5353 so that would get an answer if it did the mDNS query instead of dig. But I’m not sure how this works, so that’s just a guess.


  • Yeah you’re right, thanks. I did figure this out on my own already, see my other comment:

    Oh yeah that, so technically (and I was confused about this), the p in s/from/to/p is not the same as the p command, it’s a flag for the s command that tells it to print the output.


  • Yeah no problem.

    What’s maybe interesting is how sed came to be. Back in early days of Unix, they had ed as their editor (or, as some old manpage says, “Ed is the standard text editor.”)

    Sed has basically the same commands as ed. You typed 3d to delete the third line, or 10,20p to print lines 10 to 20. They only had teletypes back then, which are basically a keyboard and dot-matrix printer with one of those continuous papers for output, prior to when hardware terminals with CRT screens were a thing.

    Anyway, someone thought it would be useful if you could put ed-style editing commands inside shell pipelines, and ed doesn’t work for that. It is used for interactively editing files in place, and so gets commands from stdin. You can’t pipe any files into it. So the “stream editor”, sed, was born.

    Also interesting: There were improved modified versions of ed going around like em and later ex. The original vi was a “visual mode” extension for ex, and you can still run ex/ed commands from vi by typing : first, e.g. you can delete line 3 by typing :3d inside vi.


  • Oh yeah that, so technically (and I was confused about this), the p in s/from/to/p is not the same as the p command, it’s a flag for the s command that tells it to print the output. You could do multiple commands like /re/ {s/a/b/;p} for the same result, by using a {} block.

    If you do, say, /re/ s/a/b/; p those would be separate command, the first does the thing on lines matching /re/, while the p has no address range (e.g. regex) associated with it, so it gets executed for all the lines.



  • gnuhaut@lemmy.mltoLinux@lemmy.mlHelp with sed commands
    link
    fedilink
    arrow-up
    8
    ·
    edit-2
    3 days ago

    You can do something like this to emulate grep:

    sed -n '/myregex/p'
    

    The -n suppresses auto-printing. That command should interpreted as: find line matching /myregex/ and then print (p) it.

    You can then combine this with s (substitute):

    sed '/myregex/ s/from/to/ p`
    

    The complete command is then something like:

    LANG=C df -h --output=avail,source | sed -n '/\/dev\/nvme0n1p2/ s/^\s*\([0-9.]\+[KMGT]\).*/\1/ p'
    

    Note that the output can be something like 2.3G, but in my locale that would be 2,3G which is why I added LANG=C.

    Easier IMHO is awk:

    awk '/myregex/ {print $1}'
    

    prints the first field.


  • There’s some wrong things in this article, and a thing worth mentioning.

    Half-Life (and its mods like Counter-Strike) had Linux server versions, and a lot of dedicated servers ran on Linux, which I think is worth mentioning when talking about the history.

    Steam wasn’t well received at first, people didn’t like that there was now this special launcher/downloader you had to use. Mind you they moved their old games onto Steam, so it’s not like you knew about this when you bought it. Also there weren’t any games on there except Half-Life and related titles, like HL mods that got their own release.

    Contrary to what the article claims, MacOS does not support some outdated version of DirectX, it does not and never has supported DirectX at all. DirectX was only ever supported on Windows and XBox.

    DirectX also was not well received at first. Here’s an old article from gamedev.net (2002):

    What later became known as DirectX 1.0 ended up not being very widely accepted. It was buggy, slow, badly structured, and overly complex.

    Of course, Microsoft wasn’t about to just give up. They kept working at it, asking the community for ways to improve it. The first truly viable version of DirectX was DirectX 3.0. A few years later, they released DirectX 5 (skipping 4 entirely), which was the first truly useful version. Incremental improvements were made with version 6. Then came DirectX 7.0.

    DirectX 7 was the first one to actually be embraced by game developers. It worked well, making game programming reasonably easy, and a lot of people liked the interface.

    Here's a bunch of things John Carmack had to say about DirectX over the years:

    First, a rant by John Carmack from 1996:

    I have been using OpenGL for about six months now, and I have been very impressed by the design of the API, and especially it’s ease of use. A month ago, I ported quake to OpenGL. It was an extremely pleasant experience. It didn’t take long, the code was clean and simple, and it gave me a great testbed to rapidly try out new research ideas.

    I started porting glquake to Direct-3D IM with the intent of learning the api and doing a fair comparison.

    Well, I have learned enough about it. I’m not going to finish the port. I have better things to do with my time.

    John Carmack revised his opinion later. Here he is posting in 2001 about DirectX 8:

    D3D is clunky, etc

    Not really true anymore. MS made large strides with each release, and DX8 can’t be called a lousy API anymore. One can argue various points, but they are minor points. Anti-Microsoft forces have a bad habit of focusing on early problems, and not tracking the improvements that have been made in current versions. My rant of five years ago doesn’t apply to the world of today.

    But:

    All of Nvidia’s new features have showed up as OpenGL extensions before they show up as new D3D features.

    By 2011 he thought Direct3D was better than OpenGL.



  • Since you say the thing is working fine on Windows, there’s almost certainly a bug or several. I’d say probably a driver in the kernel, but could be something else. Changing distro or kernel version does sometimes help with that sort of thing, mainly because another distro may have newer or older kernels and other software, and bugs get both introduced and fixed every release.

    Freezing issues can have lots reasons, including buggy apps, RAM exhaustion due to memory leaks, bugs in the graphics drivers or graphics stack more generally, various blocking I/O things taking unexpectedly long due to network issues or faulty hardware or drivers.

    If you want a chance to figure this out, you probably need to run things in the terminal, like installing software updates through the apt and snap (?) cli utilities. GUIs are notoriously shit at reporting unexpected errors, whereas all sorts of programs (including GUI apps if you start them in a terminal) do regularly print warnings and error messages to stderr, which will show up in a terminal. This is because it’s easy for the programmers to do that with just single printf() (etc.) line.

    For driver issues, looking at the kernel logs can sometimes show interesting things as well. I will say that, when looking at logs or terminal output, there often are warnings that are completely unrelated and/or harmless, and that’s not necessarily obvious to the user.

    If this is a software issue, framework imho shouldn’t advertise their stuff being able to run Ubuntu if they cannot stay on top of issues that are happening in this configuration.





  • Yeah I wrote that stop command wrong, it’s supposed to be systemctl --user stop pulseaudio. The relevant errors from journalctl were the “busy” errors. Are they still there? Maybe they’re old messages? You can type G to go to the end of the log.

    Also, and this is probably my last suggestion, try restarting the socket with systemctl --user restart pipewire-pulse.socket. And maybe restart all the other crap as well for good measure. My theory here is that pulseaudio overwrote that socket with it’s own socket, and anything trying to play sound would be trying to connect to the nonexistent pulseaudio, and maybe restarting pipewire doesn’t actually recreate the socket, because systemd does that, but I’m not sure that’s actually how that works.

    Theoretically logging out and in again should also restart all the things pipewire I think, but it’s possible that whatever is slowing down your boot is actually slowing down the login, so do at your own risk.