Robert Kudyba wrote:
>
> > Now any idea why the original '$gecos' inserts the actual string
> $gecos
> > into FreeIPA/LDAP?
>
> It's a shell issue, single quotes prevents any argument expansion, use
> double quotes.
>
>
> Sure but using just double quotes $gecos is still added to the FreeIPA
> record. I can at least import it with "'$gecos'" but the script then
> imports the single quotes as a part of the record.
I assume you tried "$gecos"?
Yes and I found a fix. All that is needed is to surround the echo command with double quotes at the top of the script where username is set:
username="$(echo $line | cut -f1 -d:)"
> We also noticed if a NIS user has a middle initial the script errors with:
> ipa: ERROR: command 'user_add' takes at most 1 argument
There should be a way to file a doc bug within the docs themselves.
Indeed perhaps to add comments, but then those are never spam-proof.
The script was never meant to be bullet-proof. It was provided for
guidance purposes. There are *lots* of corner cases with names.
Understood but it's a great launching point. I can share what my colleague added with a couple awks to handle names in NIS that have middle initial, "last name, first name" and other permutations:
# Change Last, First to First Last. (Fill in dummy for empty gecos.)
if [ -z "$gecos" ]; then
firstlast='First Last'
else
firstlast=$(echo $gecos | sed -e 's/\(.*\), \(.*$\)/\2 \1/')
fi
# Extract First and Last into separate variables
first=$(echo $firstlast | awk '/^(\w|[-'\''])+ \w\. / { print $1, $2; } \
/^(\w|[-'\''])+ (\w|[-'\''])+( |$)/ { print $1; }' )
#echo this dollar 1 $1 this is dollar 2 $2
last=$(echo $firstlast | awk 'BEGIN {ORS=" ";} \
/^(\w|[-'\''])+ \w\. / { for (i=3; i<=NF; i++) print $i; } \
/^(\w|[-'\''])+ (\w|[-'\''])+( |$)/ { for (i=2; i<=NF; i++) print $i; }' \
| sed 's/ *$//' )
> > Logs also spit out this warning after every user is added:
>
> > Failed to set perms (3140) on file
> (/run/ipa/ccaches/admin@OURDOMAIN.EDU <mailto:admin@OURDOMAIN.EDU>)!,
>
>
> I added a comment to issue
> 7032 https://urldefense.proofpoint.com/v2/url?u=https-3A__pagure.io_freeipa_issue_7032-23comment-2D713784&d=DwIDaQ&c=aqMfXOEvEJQh2iQMCb7Wy8l0sPnURkcqADc2guUW8IM&r=X0jL9y0sL4r4iU_qVtR3lLNo4tOL1ry_m7-psV3GejY&m=X59opfrdKbUDbTLScz3EnMgDGj3HASui0JGAJwm2i5o&s=-_1fvpWeMHtgSeki3bf6aOD_P8fG2bPuts_obVgg8bo&e= not sure if
> this is still a "won't fix" issue?
It's not won't fix, it's just extremely low in priority since it doesn't
affect operation.
Thanks for acknowledging. Hope I added some value to future users that might find this thread.