Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]QProcess or system()
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]QProcess or system()

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    toho71
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • B Offline
      B Offline
      broadpeak
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • T Offline
        T Offline
        toho71
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          [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.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved