Giter VIP home page Giter VIP logo

Comments (12)

mej avatar mej commented on August 20, 2024

Without knowing what line 381 of common.nhc is in your version of NHC, I really can't say. The error basically means something is being treated as a number but isn't one, namely .RHEL72.... Do you know what that comes from? I recognize that it's something related to OmniPath, but I haven't seen that particular string before.

from nhc.

chiroptical avatar chiroptical commented on August 20, 2024

Okay, so I have time to look at this again. First, I realized I installed the *.el6.* version so I upgraded using lbnl-nhc-1.4.2-1.el7.noarch.rpm. Line 381 of common.nhc is Line 12 below:

  1 function nhc_common_parse_passwd_entry() {                                
  2     local IFS=':'                                                         
  3     local PASSWD_ENTRY="$1"                                               
  4     local UID_VAR="$2"                                                    
  5     local THIS_UID                                                        
  6     local -a LINE                                                         
  7                                                                           
  8     LINE=( $PASSWD_ENTRY )                                                
  9     THIS_UID=${LINE[2]}                                                   
 10     PWDATA_UIDS[${#PWDATA_UIDS[*]}]=$THIS_UID                             
 11     PWUID_USER[$THIS_UID]="${LINE[0]}"                                    
 12     PWUID_GID[$THIS_UID]=${LINE[3]}                                       
 13     PWUID_GECOS[$THIS_UID]="${LINE[4]}"                                   
 14     PWUID_HOME[$THIS_UID]="${LINE[5]}"                                    
 15     PWUID_SHELL[$THIS_UID]="${LINE[6]}"                                   
 16                                                                           
 17     PWDATA_USERS[${#PWDATA_USERS[*]}]="${LINE[0]}"                        
 18     if [[ $THIS_UID -lt 100 ]]; then                                      
 19         PWDATA_SYSTEM_USERS[${#PWDATA_SYSTEM_USERS[*]}]="${LINE[0]}"      
 20     fi                                                                    
 21     PWDATA_USERID_MAP="$PWDATA_USERID_MAP||${LINE[0]}:$THIS_UID"          
 22     if [[ -n "$UID_VAR" ]]; then                                          
 23         eval $UID_VAR=$THIS_UID                                           
 24     fi                                                                    
 25 }                                                                         

The following directory exists: /root/IntelOPA-Basic.RHEL72-x86_64.10.1.1.0.9. Looking at that function name and code, I don't see how it ends up with that error.

from nhc.

mej avatar mej commented on August 20, 2024

What happens if you put quotes around the part after the equals sign, like so:

PWUID_GID[$THIS_UID]="${LINE[3]}"

Does that improve things at all?

from nhc.

chiroptical avatar chiroptical commented on August 20, 2024

I tried that and adding quotes on Line 9 (above). I guess if it's complaining about 11 (above), something is going on with Line 10 (above)? I tried to echo ${PWDATA_UIDS[@]}, but it doesn't print to command line or to /var/log/nhc.log. Any thoughts?

from nhc.

bbenedetto avatar bbenedetto commented on August 20, 2024

I'm seeing the same issue with the latest zipfile.

It looks to me like it crashes on lines that have an "*" for the password entry in /etc/passwd.
If I change those to "x" (as a test), then everything works.
But I still haven't figured out WHY it is doing this.

from nhc.

bbenedetto avatar bbenedetto commented on August 20, 2024

Huh. I fixed it by changing this line in common.nhc:
LINE=( $PASSWD_ENTRY )
to:
LINE=( "$PASSWD_ENTRY" )
and it still SEEMS to work....

from nhc.

mej avatar mej commented on August 20, 2024

That's very strange. That should not be the case -- bash isn't supposed to do word splitting on double-quoted strings.

If you look at the code for nhc_common_parse_passwd_entry() that you supplied in your earlier comment, you see that the special shell variable $IFS is being set to : (a single colon). This allows the line in question (line 8 above) to split the passwd file entry into its component parts. Splitting $PASSWD_ENTRY on colons should create an array with 7 entries -- one for each /etc/passwd field. However, if it's double-quoted like you suggest, only 1 field will result.

Unless there's a bug in bash, you should be able to see this by doing the following:

bash$ (IFS=: ; PASSWD_ENTRY="a:*:c:d:e:f:g" ; FOO=( "$PASSWD_ENTRY" ) ; IFS=$' \t\n' ; echo "FOO (${#FOO[*]}):  ${FOO[*]}")
FOO (1):  a:*:c:d:e:f:g

I'm not sure why it worked for you; it shouldn't have. As you can see above, the $FOO[] array only contains 1 element, the original string, and the colons are still intact.

The issue you're seeing is that pathname expansion occurs after all other expansions, including variable expansion and word splitting. So if there are files in the directory where NHC runs, the "word" which consists of * gets replaced by multiple words, one for each file in the directory, as shown here:

bash$ (IFS=: ; PASSWD_ENTRY="a:*:c:d:e:f:g" ; FOO=( $PASSWD_ENTRY ) ; IFS=$' \t\n' ; echo "FOO (${#FOO[*]}):  ${FOO[*]}")
FOO (10):  a file1 file2 file3 file4 c d e f g

The solution is to turn off pathname expansion altogether, like this:

bash$ (set -f ; IFS=: ; PASSWD_ENTRY="a:*:c:d:e:f:g" ; FOO=( $PASSWD_ENTRY ) ; IFS=$' \t\n' ; echo "FOO (${#FOO[*]}):  ${FOO[*]}")
FOO (7):  a * c d e f g

I'm currently working on a patch which will disable it globally and only re-enable it in the specific locations where it's needed. It's not a massive change, but it's also not what I would call "trivial" either, so it will require some testing! I'll post another update when the patch is ready. :-)

Thanks for the report!

from nhc.

mej avatar mej commented on August 20, 2024

As you can see above, I just pushed a commit that will hopefully rectify the situation. If you don't mind checking out the glob-disable branch I just pushed (8fa6657) and testing to see if that fixes the problem (and making sure everything else still works!), I would definitely appreciate the assistance. :-)

from nhc.

bbenedetto avatar bbenedetto commented on August 20, 2024

from nhc.

mej avatar mej commented on August 20, 2024

You're absolutely right! My apologies for that thinko (and for the amount of time it sounds like you spent trying to track it down)! :-(

I'm happy to push that fix into the glob-disable branch this evening after work, or if you'd like to submit a PR for that, I'll gladly take it.

from nhc.

bbenedetto avatar bbenedetto commented on August 20, 2024

from nhc.

mej avatar mej commented on August 20, 2024

Oops, I missed the notification that you'd replied. Doh! :-(

Yes, PR means Pull Request. But in order to submit a Pull Request, you'd need to fork my NHC repository to one of your own, git clone yours from GitHub to your local machine, make the change to your local copy and commit it, push your repo back up to GitHub, and then submit the Pull Request to my NHC tree from yours.

And of course all that requires that you speak Git. :-)

If you want to learn, the GitHub folks have lots of great Help articles to guide you through the process, starting here: https://help.github.com/categories/collaborating-with-issues-and-pull-requests/

But if you're not comfortable with Git, I can just go ahead and push the change myself. No worries!

from nhc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.