Hi Coders,

I've uncovered an issue with our code base when using posix_spawn to create 
users for snmp.  The below is a snippet of our code.

sprintf_s(strIn, sizeof(strIn), "/usr/local/bin/snmpusm -n %c%c -v3 -u %s -l 
authNoPriv -a MD5 -A %s localhost create %s", '"', '"',
            strCloneFromUserName, strClonePassword, strUser);


printf("SNMP: execute %s\n", strCommandLine);
    while (strCommandLine[i])
    {
        argv[nArgs] = &strCommandLine[i];
        while (strCommandLine[i] && strCommandLine[i] != ' ')
        {
            ++i;
        }
        if (strCommandLine[i] == ' ')
        {
            strCommandLine[i] = 0;
            ++i;
        }
        ++nArgs;
    }
    argv[nArgs] = NULL;

posix_spawn(&pid, argv[0], NULL, NULL, argv, environ);

The behavior seen appears like the command is cut off when executing. Stating 
that no IP(localhost) was specified. We are running on centos 7 and I'm pretty 
sure this is an environment issue from when the spawn is setup. If I printf the 
command being sent to the spawn it runs to perfection.

Is this the correct approach or is there a better method built into the 
NET-SNMP library what we can compile into our binary?

Justin Cook


--- CONFIDENTIALITY NOTICE: This email and any attachments are for the 
exclusive and confidential use of the intended recipient. If you are not the 
intended recipient, please do not read, distribute or take action in reliance 
upon this message. If you have received this in error, please notify us 
immediately by return email and promptly delete this message and its 
attachments from your computer system.
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to