Ssh_keydir is not configured

Hi,

I’ve been trying to create user with a maapi as shown in confd user guide but I am getting error as below;

TRACE MAAPI_CD /aaa/authentication/users → CONFD_OK
2022-05-31T13:48:12.928467113Z TRACE MAAPI_CREATE user{furkank} → CONFD_OK
2022-05-31T13:48:12.936511166Z TRACE MAAPI_APPLY_TRANS DEBUG notset - /aaa:aaa/authentication/users/user{furkank}/ssh_keydir is not configured
2022-05-31T13:48:12.936542422Z → CONFD_ERR
2022-05-31T13:48:12.937015729Z TRACE MAAPI_STOP_TRANS → CONFD_OK

Saying ssh_keydir is not set. My code is below.

sprintf(sshkeydir,"var/confd/home/%s/.ssh",userName);
        sprintf(homedir,"home/%s",userName);
        if (maapi_cd(msock,th,"/aaa/authentication/users") != CONFD_OK)
            confd_fatal("cannot CD: %s", confd_lasterr());
        if (maapi_create(msock,th,"user{%s}",userName) != CONFD_OK)
        {
            if (maapi_set_elem2(msock,th,sshkeydir,"/aaa/authentication/users/user{%s}/ssh_keydir",userName) != CONFD_OK)
            {
                confd_fatal("failed to set ssh keydir: %s\n", confd_lasterr());
                printf("Could not create user %s \n",userName);
            }
            if (maapi_set_elem2(msock,th,"","/aaa/authentication/users/user{%s}/password",userName) != CONFD_OK)
            {
                printf("Could not create user %s \n",userName);

            }
            if (maapi_set_elem2(msock,th,homedir,"/aaa/authentication/users/user{%s}/homedir",userName) != CONFD_OK)
            {
                confd_fatal("failed to set homedir: %s\n", confd_lasterr());
                printf("Could not create user %s \n",userName);
            }
        }

Thanks in advance

I believe you want the != to be == so that if creating the “user” list entry succeeds you set the leafs for that list entry.