Commit graph

2024 commits

Author SHA1 Message Date
Jōshin
580982ea60
Remove assert.h 2023-12-15 11:35:43 -05:00
Jōshin
3bb08954f7
Merge pull request #1 from mrdomino/linux-ape
ape/loader.c parity
2023-12-15 10:15:23 -05:00
Jōshin
3b58dbbe0c
GetProgramExecutableName handles old loaders 2023-12-15 14:56:18 +00:00
Jōshin
860bf7ec17
Pathname security in GetProgramExecutableName
- Tries `KERN_PROC_PATHNAME` first on NetBSD/FreeBSD.

- Tries procfs first, but now only on Linux. (You can have /proc on
  FreeBSD, but then again, /proc could be anything on non-Linux. An
  option here is to put non-Linux /proc after the issetugid check.)

- If `issetugid()` and none of the secure methods have worked, sets
  the empty string and returns.
2023-12-15 14:34:19 +00:00
Jōshin
9fc7438b82
Loader passes executable name as rdx 2023-12-15 07:21:48 +00:00
Jōshin
abc5809db0
wip pass program path in register 2023-12-15 06:17:18 +00:00
Jōshin
4673a6f186
RealPath in ape/loader.c 2023-12-15 06:11:10 +00:00
Jōshin
809f0f5019
Turn on tests, check argv[0] 2023-12-14 20:24:23 -05:00
Jōshin
5554f32559
add StrRChr, fix BaseName 2023-12-14 20:24:22 -05:00
Jōshin
3fd424bf0d
Filename to match varname 2023-12-14 20:24:01 -05:00
Jōshin
91a70f6749
M1 loader uses realpath 2023-12-14 20:11:10 -05:00
Jōshin
2b2a38b5ae
env.com behaves more like env
It prints its own name to stderr, not stdout.

It also prints `GetProgramExecutableName()` for further debugging
convenience.
2023-12-14 19:52:49 -05:00
Jōshin
bf952027c3
ape-m1 minor formatting 2023-12-14 19:47:04 -05:00
Jōshin
57bd4bc693
rename global to __program_executable_name 2023-12-14 19:44:43 -05:00
Jōshin
daf2156b5a
New new style program path passing
The M1 loader now passes the program executable name directly as x2,
which is the third argument to `cosmo()`. From there it is assigned
to `__myname`.

`GetProgramExecutableName` now always returns `__myname`, and it is
`InitProgramExecutableName`’s job to set that variable if it is not
already assigned.

`InitProgramExecutableName` now dies if `issetugid()` and `__myname`
is null, pending a rework of the path-finding logic.
2023-12-14 19:32:49 -05:00
Jōshin
8dbfb77890
tolower() on terminfo directories (#1009)
Fixes the ncurses build on my M1 Mac. Required a make clean.
2023-12-13 12:26:12 -05:00
Jōshin
7a05fb43ac
Assume __zipos_close when closing a zipos fd 2023-12-13 10:07:32 -05:00
Jōshin
3b302e6379
Cleanup zipos vfork (#1004) 2023-12-13 01:36:44 -08:00
Jōshin
6cedbc746c
Fix type of refs 2023-12-13 03:03:25 -05:00
Jōshin
2fc507c98f
Fix more vi modelines (#1006)
* modelines: tw -> sw

shiftwidth, not textwidth.

* space-surround modelines

* fix irregular modelines

* Fix modeline in titlegen.c
2023-12-13 02:28:11 -05:00
Justine Tunney
bd10cf9d38
Whip up find command for PE binaries
Using this shell script:

    #!/bin/sh
    mkdir -p exe
    for f in $(findpe); do
      if [ -e exe/${f##*/}.exe ]; then
        cp $f exe/${f##*/}-$(rand64).exe
      else
        cp $f exe/${f##*/}.exe
      fi
    done
    rm -f /mnt/videos/microsoft.zip
    zip -rj6 /mnt/videos/microsoft.zip exe
    echo /mnt/videos/microsoft.zip

Helps file reports with Microsoft about incorrect AV detections.

See #1003
2023-12-12 10:29:03 -08:00
Justine Tunney
ae85fb74b2
Update README.md
Fixes #1002
2023-12-12 07:53:23 -08:00
Justine Tunney
f4a2a65cc8
Add bash 5.2 to third_party 2023-12-11 07:38:17 -08:00
Justine Tunney
e1f65d5f2b
Add readline 8.2 to third_party 2023-12-11 05:59:20 -08:00
Justine Tunney
cbe72c4339
Fix ncurses yoinks 2023-12-10 13:11:45 -08:00
Justine Tunney
6744de659e
Remove awful terminfo definitions
These files collide on MacOS and Windows due to case insensitivity.
2023-12-10 11:28:22 -08:00
Justine Tunney
4db6b74de7
Fix build warning error 2023-12-10 08:26:36 -08:00
Justine Tunney
128be2bd2e
Add less 643 2023-12-10 08:01:37 -08:00
Justine Tunney
0ed7309fdb
Add ncurses 6.4 2023-12-10 07:33:37 -08:00
Justine Tunney
6ee5580adc
Delete GGML and RadPajama
Please use https://github.com/mozilla-Ocho/llamafile which is better,
newer, and built on cosmocc. If you need the RadPajama model, file an
issue with llamafile asking for support.
2023-12-10 06:08:54 -08:00
Justine Tunney
4a63e4a27e
Reduce header complexity of PCRE2 2023-12-10 06:08:25 -08:00
Justine Tunney
b27e9fe845
Add PCRE2 library to third_party 2023-12-10 05:59:18 -08:00
Justine Tunney
4f66d7f2dd
Add WIN32 pseudo console APIs
See #999
2023-12-10 01:29:25 -08:00
Justine Tunney
1bd69867d1
Explain how to build FOSS in cosmocc README 2023-12-09 06:58:24 -08:00
Joseph Battelle
b0cced855d
Move tcgetpgrp and tcsetpgrp decls to unistd.h (#996) (#997) 2023-12-08 22:54:46 -08:00
Justine Tunney
076e0bf9a9
Re-disable WIN32 call tracing 2023-12-08 20:06:16 -08:00
Justine Tunney
1a96de6eda
Add libresolv from Musl Libc
Locally modified to get nameservers from Windows Registry when
`\etc\resolv.conf` isn't defined.
2023-12-08 20:04:10 -08:00
Justine Tunney
8874a37abc
Add <link.h> for absl 2023-12-08 20:04:10 -08:00
Zoey Greer
a11016e590
Use gid_t and uid_t in passwd.h (#995) 2023-12-08 18:27:41 -08:00
Jōshin
e16a7d8f3b
flip et / noet in modelines
`et` means `expandtab`.

```sh
rg 'vi: .* :vi' -l -0 | \
  xargs -0 sed -i '' 's/vi: \(.*\) et\(.*\)  :vi/vi: \1 xoet\2:vi/'
rg 'vi: .*  :vi' -l -0 | \
  xargs -0 sed -i '' 's/vi: \(.*\)noet\(.*\):vi/vi: \1et\2  :vi/'
rg 'vi: .*  :vi' -l -0 | \
  xargs -0 sed -i '' 's/vi: \(.*\)xoet\(.*\):vi/vi: \1noet\2:vi/'
```
2023-12-07 22:17:11 -05:00
Justine Tunney
90c53f3064
Fix some references to stdio/internal.h 2023-12-07 16:30:49 -08:00
Justine Tunney
f8ea02d4d1
Import /etc/shadow support from Musl for Linux
Fixes #992
2023-12-07 16:26:04 -08:00
Justine Tunney
06ace4e7b4
Always use compiler builtin for offsetof()
We have received multiple reports of GCC breaking builds when compiler
flags like `-std=c11` were being passed. The workaround until the next
release is to simply not define `__STRICT_ANSI__` which is a bad idea.
2023-12-07 14:20:12 -08:00
Justine Tunney
e36283f1d9
Support double parameters in dlsym() imports 2023-12-06 06:49:35 -08:00
Justine Tunney
4772796cd8
Improve cosmo_dlopen() documentation 2023-12-06 06:33:50 -08:00
Justine Tunney
7c39818c13
Simplify GNU Make build config 2023-12-06 03:25:16 -08:00
Jōshin
394d998315
Fix vi modelines (#989)
At least in neovim, `│vi:` is not recognized as a modeline because it
has no preceding whitespace. After fixing this, opening a file yields
an error because `net` is not an option. (`noet`, however, is.)
2023-12-05 14:37:54 -08:00
Justine Tunney
221a27836b
Define max_align_t in <stddef.h>
It was previously only being defined in <cstddef>

See oilshell/oil#1760
2023-12-05 00:52:33 -08:00
Justine Tunney
536dfb947a
Make getprogramexecutablename_test report status
Fixes #988
2023-12-04 23:19:28 -08:00
Justine Tunney
cd52c59552
Allow MAP_POPULATE under pledge() 2023-12-04 23:15:41 -08:00