Detecting user settings in "/etc/shadow"

I’m trying to get a simple output of the settings for a local account in Linux from /etc/shadow.

tools:!!:16567:7:90:14:::

So the user “tools” has a minimum password life of 7 days and a maximum password life of 90 days. I basically want my relevance just to read the minimum password setting. I found a post on the old forums that used regex to grab it but I couldn’t make it work.

preceding texts of firsts ":" of following texts of firsts ":" of following texts of firsts ":!!:" of "tools:!!:16567:7:90:14:::"
1 Like

Alternative:

(tuple string item 1 of concatenations ", " of substrings separated by ":" of following texts of firsts ":!!:" of it) of "tools:!!:16567:7:90:14:::"

This will give the max password life:

(tuple string item 2 of concatenations ", " of substrings separated by ":" of following texts of firsts ":!!:" of it) of "tools:!!:16567:7:90:14:::"

The above relevance is dependent upon ", " not appearing in the original text, which makes it problematic for use in some cases, like this sentence.

1 Like

The “:!!:” signifies accounts that are disabled but not all accounts are disabled which is why I need to determine this value. If the account is not disabled, there is a long hash value that varies by account. I removed to keep the info secure. I tried something like this:

tuple string item 4 of (substrings separated by ":" of line whose (it starts with "tools") of file "shadow" of folder "/etc")

This reads the results how I want but it’s not choosing the fourth item of the result. I’ve never been good with tuples.

Just in case it this one: the items are indexed from 0. So 4th item is item 3 of

1 Like

Noted.

Now here is the issue. The substring relevance seems to give me the answer I want:

Q:(substrings separated by ":" of line whose (it starts with "tools") of file "shadow" of folder "\etc")
A: tools
A: !!
A: 16567
A: 7
A: 90
A: 14
A: 
A: 
A: 
T: 0.458 ms

When I select the tuple items, I also get the desired result:

Q: tuple string items of (substrings separated by ":" of line whose (it starts with "satools") of file "test.txt" of folder "C:\Users\xeebk62\Desktop")
A: satools
A: !!
A: 16567
A: 7
A: 90
A: 14
T: 0.529 ms

But when I try to select a specific tuple item, I get this:

Q: tuple string item 3 of (substrings separated by ":" of line whose (it starts with "tools") of file "shadow" of folder "/etc")
E: Singular expression refers to nonexistent object.

You’ll want to concatenate the separate answers into a tuple first and then you can pull out a specific item:

tuple string item 3 of (concatenation ", " of (substrings separated by ":" of line whose (it starts with "tools") of file "shadow" of folder "/etc"))
1 Like

That did it. As I said, tuples are not my strong suit. Thanks, gents.

1 Like