Commit Graph

30 Commits

Author SHA1 Message Date
Allen Bai 6733843f87 lib/util: Fix segfault when validating filename
This change fixes the segfault issue when calling ostree_repo_checkout_tree with
empty GFileInfo. A simple condition check for NULL value is added at
src/libotutil/ot-unix-utils.c:46. Closes: ostreedev#1864.

Closes: #1868
Approved by: jlebon
2019-06-06 16:05:19 +00:00
Marcus Folkesson 6bf4b3e1d8 Add SPDX-License-Identifier to source files
SPDX License List is a list of (common) open source
licenses that can be referred to by a “short identifier”.
It has several advantages compared to the common "license header texts"
usually found in source files.

Some of the advantages:
* It is precise; there is no ambiguity due to variations in license header
  text
* It is language neutral
* It is easy to machine process
* It is concise
* It is simple and can be used without much cost in interpreted
  environments like java Script, etc.
* An SPDX license identifier is immutable.
* It provides simple guidance for developers who want to make sure the
  license for their code is respected

See http://spdx.org for further reading.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>

Closes: #1439
Approved by: cgwalters
2018-01-30 20:03:42 +00:00
Matthew Leeds 2a9c5efe1d lib/utils: Check for invalid UTF-8 in filenames
In case a filename contains invalid UTF-8 characters, libostree will
pass it to g_variant_builder_add() in create_tree_variant_from_hashes()
anyway, which leads to a critical warning from glib and an invalid
commit. This commit makes ostree print a useful error and exit instead.

Closes: #1271
Approved by: cgwalters
2017-10-14 00:47:40 +00:00
Colin Walters 7f6af94c5a lib/utils: Port a bit to decl-after-stmt style
Add add some more comments.

Closes: #1247
Approved by: jlebon
2017-10-05 13:28:59 +00:00
Colin Walters 6e4146a354 tree-wide: Remove Emacs modelines
We added a `.dir-locals.el` in commit: 9a77017d87
There's no need to have it per-file, with that people might think
to add other editors, which is the wrong direction.

Closes: #1206
Approved by: jlebon
2017-09-21 21:38:34 +00:00
Colin Walters 88a1fc92a9 tree-wide: Add+run spatch to use glnx_throw()
I had to run a sed job to add whitespace after, but otherwise this was easy.

Closes: #890
Approved by: jlebon
2017-05-26 19:27:11 +00:00
Colin Walters ee626c2654 libutil: Delete some unused error handling APIs
The first one is better as `err`, the second might as well just call `err` too.

Closes: #767
Approved by: jlebon
2017-03-30 13:14:43 +00:00
Matthew Barnes bb231fdf74 Use g_autoptr(GPtrArray) instead of gs_unref_ptrarray 2015-05-06 22:07:10 -04:00
Giuseppe Scrivano e8cbd4b8c5 Remove magic argument numbers to exit(2)
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-01-30 15:27:36 +01:00
Giuseppe Scrivano ea4683ba06 Remove unused <dirent.h>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-01-30 15:27:36 +01:00
Colin Walters 1e8e070102 Port to libgsystem errno API, hard depend on 2014.3
This is long overdue to make it to libgsystem.  Update our dependency.
2015-01-04 21:17:11 -05:00
Colin Walters 3b9da094d8 main: Drop log builtin
We may revive this later, but commits in their current form aren't
very useful for humans to read, so it doesn't make sense to have a
tool to show a history of useless stuff.

More interesting things are diffs between commits, object statistics,
etc.
2013-07-23 18:19:14 -04:00
Colin Walters 124416d832 Use AC_USE_SYSTEM_EXTENSIONS instead of #define _GNU_SOURCE
It's less copy/paste, works everywhere, etc.

Also fix some missing #include "config.h".
2013-07-10 13:25:35 -04:00
Colin Walters 4b170d656c Switch to libgsystem local allocation macros
And drop our compatibility wrapper.
2013-07-07 12:27:44 -04:00
Colin Walters cd5fce713c core: Reuse more libgsystem API in utils
More code drain to libgsystem.
2013-01-04 19:46:02 -05:00
Colin Walters 47bd290065 core: Drain fdatasync() API into libgsystem
Just code cleanup.
2013-01-04 17:25:32 -05:00
Colin Walters 4d2f770748 core: Use O_NOATIME to open metadata
We really don't need atime for metadata, it's just a speed hit.
2012-08-27 16:07:39 -04:00
Colin Walters 2396608754 repo: Call fdatasync() before adding objects to the repo
I run builds on my laptop, but it also crashes about 1/4 of the time
while suspending.  It's definitely undesrirable to get e.g. empty
.dirtree objects because they corrupt builds.  Concretely, I was
getting empty contents committed for xorg-util-macros.

Now, we used to write out temporary files using g_file_replace() which
does a fsync() during close, but then switched to a more "manual"
g_file_append_to().

We could switch back to g_file_replace(), but the problem is, we don't
want to call fsync() on temporary files in the case where we already
have the object.  Attempting to add an object we already have is a
*very* common case.

This is both the old and new code sequence for the case where an
object is already stored:

open(temp, O_WRONLY)
write() write() write()
close()
lstat(objects/3a/9fe332...) = 0
unlink(temp)

In the *new* code, here's the case where an object *isn't* stored:

open(temp, O_WRONLY)
write() write() write()
close()
lstat(objects/3a/9fe332...) = -1
open(temp, O_RDONLY)
fdatasync()
close()
rename(temp, objects/3a/9fe332)

Compare with the *old* code path for when an object isn't stored:

open(temp, O_WRONLY)
write() write() write()
close()
lstat(objects/3a/9fe332...) = -1
link(temp, objects/3a/9fe332)
unlink(temp)

The problem with this is we really need to fdatasync().  Also doing
just rename() instead of the weird link()/unlink() helps us express to
the filesystem that we want atomic semantics.  For example, BTRFS has
special handling for rename().
2012-08-27 15:35:40 -04:00
Colin Walters 87f45052af core: Port libotutil to local-alloc 2012-04-09 15:57:46 -04:00
Colin Walters 786ce3b560 core: Preemptively error out on paths longer than PATH_MAX
Just noticed this while thinking like an attacker.
2011-12-22 16:50:01 -05:00
Colin Walters d6ceb91c35 core: Make ot_transfer_out_value() take a & for the second argument
As Ray Strode argued, it's confusing to have something that looks like
a function be magical.  And OT_TRANSFER_OUT_VALUE is uglier.
2011-12-08 17:31:45 -05:00
Colin Walters ae3a5e3c07 core: Clean up filename utility API
Remove more unused functions, and change pathname splitting to handle
more cases like duplicate //, and to throw an error on .. as a filename.
2011-12-04 12:12:34 -05:00
Colin Walters 7545405b73 core: Delete some dead utility code 2011-12-02 19:54:53 -05:00
Colin Walters 0003e101f6 core: New ot_transfer_out_value() macro
This makes out values considerably less typing.
2011-12-02 18:17:06 -05:00
Colin Walters c7235182a4 core: Use g_io_error_from_errno() to ensure we have more useful error codes 2011-12-02 11:40:06 -05:00
Colin Walters aa865bbb83 core: Validate file names read from directory variants
In a future where we pull data from remote servers, we don't want
to allow path uplinks.
2011-11-16 23:23:30 -05:00
Colin Walters 18f0b537a4 build: Move sources into src/ again
This is necessary if we want to build when srcdir == builddir,
otherwise we blow up because "ostree" is a source directory and a
binary.
2011-11-14 15:39:38 -05:00
Colin Walters 21c7ff74b6 De-recursify source tree 2011-11-02 15:45:32 -04:00
Colin Walters 03943c659f Drop glib requrirement to 2.28
This lets it build on more currently-released systems like Fedora 15.
2011-10-26 14:12:13 -04:00
Colin Walters b27df6fd72 "Hacktree" is now known as "OSTree"
It just sounds better.
2011-10-18 14:44:48 -04:00