An implementation of sudo for DOS, to run the given command with full privileges. It can be used to edit important system files, run disk partitioning tools, and so on!

all 6 comments

sorted by: hot top controversial new old
[–] 8 points 8 months ago (5 children)

But DOS is a single user mode OS?????

  • source
  • hideshow 5 child comments
  • [–] 5 points 8 months ago*

    If I'm understanding this correctly, it works for protected mode DOS, as in the DOS that Windows 95 and 98 run on top of.

    In this case, this implementation of SUDO drops the CPU out of protected mode and runs whatever command in real mode, which is 16 bit 8086 compatible and limited to 1MB of RAM.

    Unless I'm missing something here anyways..

  • source
  • parent
  • [–] 3 points 8 months ago

    Sure, but anyone can sit at that computer. Talking from experience as the kid that used my parents computer running DOS, I could freely edit config.sys and autoexec.bat to the annoyance of my parents.
    With SUDO for DOS I can imagine only those authorized will be able to edit important system files.
    I don't imagine many people are running DOS on the family computer anymore, but still useful.

  • source
  • parent
  • [–] [S] 2 points 8 months ago (1 child)

    That's true! Since there is no privilege separation in DOS, it needs to do no elevation so it can just execute the command directly. But should a future version of DOS implement unprivileged users or age verification, SUDO can be extended to support it.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 2 points 8 months ago*

    Guess you never heard of 32 bit DOS that ticks underneath Windows 95 and 98.

    Read the ASM file, the literal first line is bits 16

    It legit forces the CPU out of protected mode and back into real mode, even and especially under a protected mode 32 bit OS.

  • source
  • parent
  • 21 comments in c/programmer_humor@programming.dev view that post
    [–] 29 points 8 months ago

    If a file SUDOERS.SYS is present in the root directory of the boot drive, it is ignored.

    Just like Microslop would have done it!

  • source
  • [–] 22 points 8 months ago (6 children)

    Real joke: Being advertised as .com file, actually compiles to .exe format (which is funnier because by later DOS versions a lot of the .com files that came with DOS were actually .exe files)

  • source
  • hideshow 6 child comments
  • [–] 16 points 8 months ago* (4 children)

    Fun fact: all Windows exe files are also com files. They all have a dos running part, most of which simply prints "this program cannot be run in dos mode" and exits, but some programs do have fully functional dos program as well as the usual windows GUI part, all in one exe.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 11 points 8 months ago* (1 child)

    Technically that segment is not a com file. They are MZ exe files. com files have no metadata or header.

    There are actually 3 exe variants, MZ, NE, and the modern PE

  • source
  • parent
  • hideshow 1 child comment
  • [–] 3 points 8 months ago (1 child)

    I actually first thought that was weird and wasteful. Then I remembered that, uh, Commodore 64 often uses a similar thing. Basically, a lot of assembly and compiled languages just put the machine code into the BASIC memory, preceded by a stub BASIC program that's basically just "10 SYS addr" with that address pointing just past the end of the stub program itself. BASIC's LOAD command handles it just fine because program files don't have any header information besides load address. BASIC handles the loaded program just normally because the program has the end token, so as long as you don't modify the BASIC program, it'll be fine.

  • source
  • parent
  • hideshow 1 child comment
  • [–] [S] 3 points 8 months ago

    Luckily the .exe's MZ header is pretty small. But in this case it was necessary: when DOS loads a .com binary, it can't know how much memory it will need, so DOS just gives it all free memory. But then the program can't launch another, because all memory is in use. So that's why I had to add the MZ header which allows specifying the memory needs.

  • source
  • parent
  • [–] 9 points 8 months ago

    ReactOS developers starting to heavily take notes

  • source
  • [–] 7 points 8 months ago*

    The interpreter is then executed in unprotected real mode for full privileges.

    Good thing I'm running sudo from real mode so it can elevate me to real mode

  • source
  • [–] 5 points 8 months ago (3 children)

    I thought DOS didn't have users, meaning you were root by default

  • source
  • hideshow 3 child comments
  • [–] 4 points 8 months ago (4 children)

    Interesting timing since there is sudo in one of the latest Windows preview builds…

  • source
  • hideshow 4 child comments
  • [–] 4 points 8 months ago (3 children)

    M$ sudo has been around for a while as a dev setting iirc.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 4 points 8 months ago (2 children)

    Microsoft officially introduced a native sudo command for Windows with the release of Windows 11 Insider Preview Build 26052, which was announced on February 8, 2024.

    That, to me, is "recently". :)

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 8 months ago (1 child)

    Since when did DOS have any system level permissions? Maybe something after version 6 but I thought literally anyone could run anything at any time. Was a loooooooooong time ago though so I’m probably wrong.

  • source
  • hideshow 1 child comment
  • 6 comments in c/retrocomputing@piefed.social view that post
    [–] 1 point 7 months ago (5 children)

    But DOS is a single user mode OS?????

  • source
  • hideshow 5 child comments
  • [–] 1 point 7 months ago

    Sure, but anyone can sit at that computer. Talking from experience as the kid that used my parents computer running DOS, I could freely edit config.sys and autoexec.bat to the annoyance of my parents.
    With SUDO for DOS I can imagine only those authorized will be able to edit important system files.
    I don't imagine many people are running DOS on the family computer anymore, but still useful.

  • source
  • parent
  • [–] [S] 1 point 7 months ago (1 child)

    That's true! Since there is no privilege separation in DOS, it needs to do no elevation so it can just execute the command directly. But should a future version of DOS implement unprivileged users or age verification, SUDO can be extended to support it.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 7 months ago

    Guess you never heard of 32 bit DOS that ticks underneath Windows 95 and 98.

    Read the ASM file, the literal first line is bits 16

    It legit forces the CPU out of protected mode and back into real mode, even and especially under a protected mode 32 bit OS.

  • source
  • parent
  • [–] 1 point 7 months ago

    If I'm understanding this correctly, it works for protected mode DOS, as in the DOS that Windows 95 and 98 run on top of.

    In this case, this implementation of SUDO drops the CPU out of protected mode and runs whatever command in real mode, which is 16 bit 8086 compatible and limited to 1MB of RAM.

    Unless I'm missing something here anyways..

  • source
  • parent