summaryrefslogtreecommitdiff
path: root/src/shared/edit-util.c
Commit message (Collapse)AuthorAgeFilesLines
* string-util: add strstrafter()Lennart Poettering2023-04-141-4/+2
| | | | | | | | | strstrafter() is like strstr() but returns a pointer to the first character *after* the found substring, not on the substring itself. Quite often this is what we actually want. Inspired by #27267 I think it makes sense to add a helper for this, to avoid the potentially fragile manual pointer increment afterwards.
* edit-util: improve log messagesMike Yuan2023-04-071-3/+6
|
* edit-util: introduce overwrite_with_origin switchMike Yuan2023-04-071-1/+3
| | | | | | | Before this commit, if `original_path` is given, it will always be used to overwrite `path`. After this commit, it's controlled by the newly-added switch `overwrite_with_origin`.
* edit-util: make original_path and comment_paths work togetherMike Yuan2023-04-071-67/+47
|
* edit-util: alloc correct amount of memoryMike Yuan2023-03-221-1/+1
|
* copy: Move chattr arguments to full function signaturesDaan De Meyer2023-03-211-1/+1
| | | | | These are almost never used, so let's move them to the _full() functions signatures.
* edit-util: log unexpected errors if we fail to remove the parent dirMike Yuan2023-03-151-2/+2
|
* edit-util: use path_equalMike Yuan2023-03-151-1/+1
|
* edit-util: rename trim_edit_marker to strip_edit_temp_fileMike Yuan2023-03-131-13/+14
| | | | with some minor cleanups
* edit-util: always create temp fileMike Yuan2023-03-131-0/+11
| | | | even if neither original_path nor comment_paths is specified.
* edit-util: minor cleanupsMike Yuan2023-03-131-7/+3
| | | | | Reuse unlink_and_free() and avoid unnecessary call to rmdir()
* edit-util: unlink temporary file on failureYu Watanabe2023-03-111-1/+1
| | | | | Addresses the suggestion https://github.com/systemd/systemd/pull/26756#discussion_r1133078705.
* edit-util: fix potentical crash when no edit markersYu Watanabe2023-03-111-18/+26
| | | | This also makes trim_edit_markers() take EditFile as the argument.
* edit-util: make create_edit_temp_file() take EditFile as the argumentYu Watanabe2023-03-111-45/+32
| | | | No functional changes, just refactoring.
* edit-util: make EditFile take reference of EditFileContextYu Watanabe2023-03-111-0/+1
| | | | No functional change, just preparation for later commits.
* edit-util: several cleanups for run_editorMike Yuan2023-03-111-65/+63
| | | | | | run_editor is now switched to heap allocation for simplicity. The code for child is made into an individual function for simpler error handling.
* edit-util: introduce EditFileContextMike Yuan2023-03-111-17/+134
| | | | | | | | | | | | | | | | | | This is a rather large change which moves the add and install logic into edit-util. We store an EditFile array and the number of elements, along with the edit markers used in temporary files and whether to remove the parent directories of the target files if they're empty in an EditFileContext object. Call edit_files_add() to add an file to edit, and do_edit_files_and_install() to do the actual editing (through create_edit_temp_file(), run_editor() and trim_edit_markers()). After that, edit_file_context_done() can be used to destroy the object.
* edit-util: several cleanups to create_edit_temp_fileMike Yuan2023-03-111-40/+47
| | | | | | | original_path and comment_paths can now be used together. Removes reference to "unit"
* shared: extract edit-util from systemctl-editMike Yuan2023-03-111-0/+261