Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 1825  / 3 Years ago, thu, november 18, 2021, 1:56:18

I am working on a QT application which makes the usage of crontab easier with GUI. But I am facing the trouble of including the jobs in the crontab file from my application .
So how do i open a crontab file in c++ application in order to edit it.
Any kind of help is appreciated.
Thank you


More From » filesystem

 Answers
0

I found here this function in C:



static int opentab(int uid, char *file, int how)
/* Open a crontab file under the given uid. How is 'r' or 'w'. Return
* the result of open(2).
*/
{
uid_t safe_uid;
int flags, r, err;

switch (how) {
case 'r': flags= O_RDONLY; break;
case 'w': flags= O_WRONLY | O_CREAT | O_TRUNC; break;
default: errno= EINVAL; return -1;
}

#if __minix && !__minix_vmd
/* Standard Minix has no saved uid, so use the lousy old access(). */
if (uid != 0) {
if (access(file, how == 'r' ? R_OK : W_OK) < 0) return -1;
}
#endif

safe_uid= geteuid();
seteuid(uid);
r= open(file, flags, 0666);
err= errno;
seteuid(safe_uid);
errno= err;
return r;
}


Maybe this can be helpful for you.


[#31208] Thursday, November 18, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
scusaper

Total Points: 335
Total Questions: 111
Total Answers: 119

Location: Belize
Member since Mon, Jun 20, 2022
2 Years ago
;