~pr0gg3d/ubuntu/oneiric/util-linux/bug-805886

« back to all changes in this revision

Viewing changes to hwclock/hwclock.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2009-09-24 12:31:29 UTC
  • Revision ID: james.westby@ubuntu.com-20090924123129-y7lnqpvpnqek50dk
Tags: 2.16-1ubuntu4
* Removed access checks for hardware clock when called with --systz,
  since we may not have the rtc device at the point we run hwclock.
  I believe this is the cause of LP: #436076.
* Set kernel timezone even when the hardware clock is in UTC.
  LP: #426886.

* Don't step the system clock, or save the hardware clock on upgrades
  in case the time isn't quite correct.  LP: #430878.
* Remove the hwclock.sh and hwclockfirst.sh scripts on upgrades, since
  these are now Upstart jobs.  LP: #434767.

Show diffs side-by-side

added added

removed removed

Lines of Context:
754
754
 
755
755
 
756
756
static int
757
 
set_system_clock_timezone(const bool testing) {
 
757
set_system_clock_timezone(const bool universal, const bool testing) {
758
758
/*----------------------------------------------------------------------------
759
759
   Reset the System Clock from local time to UTC, based on its current
760
 
   value and the timezone.
 
760
   value and the timezone unless universal is TRUE.
761
761
 
762
762
   Also set the kernel time zone value to the value indicated by the
763
763
   TZ environment variable and/or /usr/lib/zoneinfo/, interpreted as
792
792
#endif
793
793
 
794
794
  gettimeofday(&tv, NULL);
795
 
  tv.tv_sec += minuteswest * 60;
 
795
  if (!universal)
 
796
    tv.tv_sec += minuteswest * 60;
796
797
 
797
798
  if (debug) {
798
799
    struct tm broken_time;
1147
1148
    int rc;  /* local return code */
1148
1149
    bool no_auth;  /* User lacks necessary authorization to access the clock */
1149
1150
 
1150
 
    no_auth = ur->get_permissions();
1151
 
    if (no_auth)
1152
 
          return EX_NOPERM;
 
1151
    if (!systz) {
 
1152
      no_auth = ur->get_permissions();
 
1153
      if (no_auth)
 
1154
              return EX_NOPERM;
 
1155
    }
1153
1156
 
1154
1157
    if (!noadjfile && (adjust || set || systohc || (!utc && !local_opt))) {
1155
1158
      rc = read_adjtime(&adjtime);
1230
1233
            return rc;
1231
1234
          }
1232
1235
        } else if (systz) {
1233
 
          if (!universal) {
1234
 
            rc = set_system_clock_timezone(testing);
1235
 
            if (rc) {
1236
 
              printf(_("Unable to set system clock.\n"));
1237
 
              return rc;
1238
 
            }
1239
 
          } else if (debug) {
1240
 
            printf(_("Clock in UTC, not changed.\n"));
 
1236
          rc = set_system_clock_timezone(universal, testing);
 
1237
          if (rc) {
 
1238
            printf(_("Unable to set system clock.\n"));
 
1239
            return rc;
1241
1240
          }
1242
1241
        }
1243
1242
        if (!noadjfile)
1655
1654
 
1656
1655
        if (debug)
1657
1656
                out_version();
1658
 
        determine_clock_access_method(directisa);
1659
 
        if (!ur) {
1660
 
                fprintf(stderr,
1661
 
                        _("Cannot access the Hardware Clock via "
1662
 
                          "any known method.\n"));
1663
 
                if (!debug)
 
1657
        if (!systz) {
 
1658
                determine_clock_access_method(directisa);
 
1659
                if (!ur) {
1664
1660
                        fprintf(stderr,
1665
 
                                _("Use the --debug option to see the details "
1666
 
                                  "of our search for an access method.\n"));
1667
 
                hwclock_exit(1);
 
1661
                                _("Cannot access the Hardware Clock via "
 
1662
                                  "any known method.\n"));
 
1663
                        if (!debug)
 
1664
                                fprintf(stderr,
 
1665
                                        _("Use the --debug option to see the "
 
1666
                                          "details of our search for an access "
 
1667
                                          "method.\n"));
 
1668
                        hwclock_exit(1);
 
1669
                }
1668
1670
        }
1669
1671
 
1670
1672
        rc = manipulate_clock(show, adjust, noadjfile, set, set_time,