-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app: add temp test command, note, this is mainly for testing
As tilte. This adds a 'temp-convert' command to rpm-ostree. The main goal of this command is to convert the AH's /usr/lib/passwd and /usr/lib/group for testing purposes. This can be useful to find whether your output for conversion is correct when testing on real-world entries
- Loading branch information
1 parent
b9aefd9
commit ec396b6
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "config.h" | ||
#include "libglnx.h" | ||
#include "rpmostree-util.h" | ||
#include "rpmostree-json-parsing.h" | ||
#include "rpmostree-passwd-util.h" | ||
#include "rpmostree-builtins.h" | ||
|
||
static char *opt_conversion_location; | ||
|
||
|
||
static GOptionEntry conversion_option_entries[] = { | ||
{ "conversion_dir", 0, 0, G_OPTION_ARG_STRING, &opt_conversion_location, "Directory to convert", "CONVERSION_DIR"}, | ||
{ NULL } | ||
}; | ||
|
||
// Temporarily take one argument --> mainly to convert the entries from /usr/lib/passwd into | ||
// entries into sysusers.d | ||
gboolean rpmostree_builtin_temp_convert (int argc, | ||
char **argv, | ||
RpmOstreeCommandInvocation *invocation, | ||
GCancellable *cancellable, | ||
GError **error) | ||
{ | ||
g_autoptr(GOptionContext) context = g_option_context_new (""); | ||
if (!rpmostree_option_context_parse (context, | ||
conversion_option_entries, | ||
&argc, &argv, | ||
invocation, | ||
cancellable, | ||
NULL, NULL, NULL, NULL, NULL, error)) | ||
return FALSE; | ||
g_print("Hi, this is a test\n"); | ||
|
||
/* Test the output for conversion, right now we can already convert the content into one string conten. The next step would just be to write a function to write sysusers entries to a new place */ | ||
const char* passwd_content = glnx_file_get_contents_utf8_at (AT_FDCWD, "/usr/lib/passwd", NULL, cancellable, error); | ||
const char* group_content = glnx_file_get_contents_utf8_at (AT_FDCWD, "/usr/lib/group", NULL, cancellable, error); | ||
|
||
g_print ("%s\n", passwd_content); | ||
g_print ("%s\n", group_content); | ||
// g_autoptr(GPtrArray) converted_ents = | ||
g_autoptr(GPtrArray) passwd_ents = rpmostree_passwd_data2passwdents (passwd_content); | ||
g_autoptr(GPtrArray) group_ents = rpmostree_passwd_data2groupents (group_content); | ||
g_autoptr(GPtrArray) sysusers_entries = NULL; | ||
rpmostree_passwdents2sysusers (passwd_ents, &sysusers_entries, error); | ||
rpmostree_groupents2sysusers (group_ents, &sysusers_entries, error); | ||
|
||
g_autofree char* sysuser_converted_content = NULL; | ||
rpmostree_passwd_sysusers2char (sysusers_entries, &sysuser_converted_content, error); | ||
|
||
g_print("%s", sysuser_converted_content); | ||
|
||
return TRUE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters