- Sep 13, 2017
-
-
Colin Walters authored
Having our tests forced into a `goto out` style is seriously annoying since we can't write tests like we write production code. Add a macro that checks for the error being NULL. This doesn't fully solve the problem since the test functions are still forced into `void` returns; at some point I may extend GLib to have `g_test_add_err_func()`.
-
- Sep 12, 2017
-
-
Colin Walters authored
I was working on rpm-ostree unified core, and hit the fact that `glnx_file_copy_at()` had the same bug with `fsetxattr()` and files whose mode is <= `0400` (e.g. `000` in the case of `/etc/shadow`) that libostree did a while ago. Basically, Linux currently allows `write()` on non-writable open files but not `fsetxattr()`. This situation is masked for privileged (i.e. `CAP_DAC_OVERRIDE`) code. Looking at this, I think it's cleaner to convert to `O_TMPFILE` here, since that code already handles setting the tmpfile to mode `0600`. Now, this *is* a behavior change in the corner case of existing files which are symbolic links. Previously we'd do an `open(O_TRUNC)` which would follow the link. But in the big picture, I think the use cases for `open(O_TRUNC)` are really rare - I audited all callers of this in ostree/rpm-ostree/flatpak, and all of them will be fine with this behavior change. For example, the ostree `/etc` merge code already explicitly unlinks the target beforehand. Other cases like supporting `repo/pubring.gpg` in an ostree repo being a symlink...eh, just no. Making this change allows us to convert to new style, and brings all of the general benefits of using `O_TMPFILE` too.
-
Colin Walters authored
While reading a strace I noticed a double close in the tests; this was because we were missing an assignment to `-1` in the tests. However, let's make supporting this clearer by explicitly supporting the fd being `-1` while still setting the `initialized` variable to `FALSE`. We also add the `EBADF` assertion checking.
-
- Sep 07, 2017
-
-
Colin Walters authored
This is a very common pattern in both ostree/rpm-ostree. Make a better API for this. I thought a lot about simply zeroing out `struct stat` but that feels dangerous; none of the values have seem obviously `cannot be zero`.
-
- Jul 24, 2017
-
-
Colin Walters authored
It'd be really nice if gtest had a variant which had the funcs take `GError`. May work on that.
-
- Jul 17, 2017
-
-
Colin Walters authored
Mostly in ostree/rpm-ostree, we work in either raw `int fd`, or `G{Input,Output}Stream`. One exception is the rpm-ostree `/etc/passwd` handling, which uses `FILE*` since that's what glibc exposes. And in general, there are use cases for `FILE*`; the raw `GUnixOutputStream` for example isn't buffered, and doing so via e.g. `GBufferedOutputStream` means allocating *two* GObjects and even worse going through multiple vfuncs for every write. `FILE*` is used heavily in systemd, and provides buffering. It is a bit cheaper than gobjects, but has its own trap; by default every operation locks a mutex. For more information on that, see `unlocked_stdio(3)`. However, callers can avoid that by using e.g. `fwrite_unlocked`, which I plan to do for most users of `FILE*` that aren't writing to one of the standard streams like `stdout` etc.
-
- Jul 10, 2017
-
-
Colin Walters authored
Work around an older glibc bug.
-
- Jun 28, 2017
-
-
Colin Walters authored
Not sure how I missed this before.
-
- Jun 26, 2017
-
-
Colin Walters authored
Besides doing `TEMP_FAILURE_RETRY` and `GError` conversion, these also prefix the error with arguments.
-
- Mar 02, 2017
-
-
Colin Walters authored
I want the `RENAME_EXCHANGE` version for rpm-ostree, to atomically swap `/usr/share/rpm` (a directory) with a new verison. While we're here we might as well expose `RENAME_NOREPLACE` in case something else wants it. These both have fallbacks to the non-atomic version. Closes: https://github.com/GNOME/libglnx/pull/36
-