Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Re: Setting time without root privileges?
Hi,
> I'm not shure whether vdr uses the date command
No, it uses the function "stime" in file eit.c:
bool cMJD::SetSystemTime()
{
struct tm *ptm;
time_t loctim;
struct tm tm_r;
ptm = localtime_r(&mjdtime, &tm_r);
loctim = time(NULL);
if (abs(mjdtime - loctim) > 2)
{
isyslog(LOG_INFO, "System Time = %s (%ld)\n", ctime(&loctim),
loctim);
isyslog(LOG_INFO, "Local Time = %s (%ld)\n", ctime(&mjdtime),
mjdtime);
if (stime(&mjdtime) < 0)
esyslog(LOG_ERR, "ERROR while setting system time: %m");
return true;
}
return false;
}
The man page:
STIME(2) Linux Programmer's Manual STIME(2)
NAME
stime - set time
SYNOPSIS
#define _SVID_SOURCE /* glibc2 needs this */
#include <time.h>
int stime(time_t *t);
DESCRIPTION
stime sets the system's idea of the time and date. Time,
pointed to by t, is measured in seconds from
00:00:00 GMT January 1, 1970. stime() may only be executed by
the super user.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and
errno is set appropriately.
ERRORS
EPERM The caller is not the super-user.
CONFORMING TO
SVr4, SVID, X/OPEN
NOTES
Under glibc2, <time.h> only provides a prototype when
_SVID_SOURCE is defined.
SEE ALSO
date(1), settimeofday(2)
--
m | Siemens VDO Automotive AG
<o) | Dipl.-Ing. (FH) Juergen Hahn, SV I IS SW3, CM, CD, DVD
(_)= | 6912.4.G8, Wernerwerkstr. 2, D-93049 Regensburg
" | Tel.: +49-941-202-5257, Fax.: +49-941-202-5192
Home |
Main Index |
Thread Index