[SOLVED]QProcess or system()



  • Should I use some QP or System() when I want to set the system time and date from my app in linux
    and for the testing I would like to log in as root but I realy dont't know how to.

    Later the program is going to run with root privilige but I need to test it.
    /T



  • Setting datetime:

    @
    #include <sys/time.h>
    #include <stdio.h>
    #include <errno.h>

    int main(int argc, char *argv[])
    {
    struct timeval now;
    int rc;

    now.tv_sec=866208142;
    now.tv_usec=290944;
    
    rc=settimeofday(&now, NULL);
    if(rc==0) {
        printf("settimeofday() successful.\n");
    }
    else {
        printf("settimeofday() failed, "
        "errno = %d\n",errno);
        return -1;
    }
    
    return 0;
    

    }
    @

    Setuid - running program from progam as root, maybe this helps:
    http://www.gnu.org/software/libc/manual/html_node/Setuid-Program-Example.html



  • thanks and on monday I'll try your code and show my code too where the sytem gives a message back that this operation isn't allowed without the root priv


  • Moderators

    [quote author="toho71" date="1328269270"]for the testing I would like to log in as root but I realy dont't know how to.
    [/quote]

    Well, that is not a Qt issue.

    Somebody must have set up your linux installation. Only whoever that was can provide you with the details of login as root respectively provide you with root privilege.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.