View | Details | Raw Unified | Return to bug 252854
Collapse All | Expand All

(-)cpdup.c 2020-12-18 11:44:13.853719000 +0100 (-2 / +18 lines)
Lines 1252-1259 Link Here
1252
                     );
1252
                     );
1253
                     ++r;
1253
                     ++r;
1254
               } else {
1254
               } else {
1255
                   if (DstRootPrivs || ChgrpAllowed(stat1->st_gid))
1255
                   if (DstRootPrivs || ChgrpAllowed(stat1->st_gid)) {
1256
                       hc_lchown(&DstHost, path, stat1->st_uid, stat1->st_gid);
1256
                       struct timeval tv[2];
1257
1258
                       bzero(tv, sizeof(tv));
1259
                       tv[0].tv_sec = stat1->st_mtime;
1260
                       tv[1].tv_sec = stat1->st_mtime;
1261
1262
                       hc_lutimes(&DstHost, path, tv);
1263
                       hc_lchown(&DstHost, path, stat1->st_uid, stat1->st_gid);
1264
                   }
1265
1257
                   /*
1266
                   /*
1258
                    * there is no lchmod() or lchflags(), we 
1267
                    * there is no lchmod() or lchflags(), we 
1259
                    * cannot chmod or chflags a softlink.
1268
                    * cannot chmod or chflags a softlink.
Lines 1273-1278 Link Here
1273
               if (VerboseOpt >= 3)
1282
               if (VerboseOpt >= 3)
1274
                   logstd("%-32s nochange", (dpath ? dpath : spath));
1283
                   logstd("%-32s nochange", (dpath ? dpath : spath));
1275
               if (!OwnerMatch(stat1, &st2)) {
1284
               if (!OwnerMatch(stat1, &st2)) {
1285
                  struct timeval tv[2];
1286
1287
                   bzero(tv, sizeof(tv));
1288
                   tv[0].tv_sec = stat1->st_mtime;
1289
                   tv[1].tv_sec = stat1->st_mtime;
1290
1291
                   hc_lutimes(&DstHost, dpath, tv);
1276
                   hc_lchown(&DstHost, dpath, stat1->st_uid, stat1->st_gid);
1292
                   hc_lchown(&DstHost, dpath, stat1->st_uid, stat1->st_gid);
1277
                   if (VerboseOpt >= 3)
1293
                   if (VerboseOpt >= 3)
1278
                       logstd(" (uid/gid differ)");
1294
                       logstd(" (uid/gid differ)");
(-)hcproto.c 2020-12-18 11:40:31.001138000 +0100 (+57 lines)
Lines 42-47 Link Here
42
static int rc_symlink(hctransaction_t trans, struct HCHead *);
42
static int rc_symlink(hctransaction_t trans, struct HCHead *);
43
static int rc_rename(hctransaction_t trans, struct HCHead *);
43
static int rc_rename(hctransaction_t trans, struct HCHead *);
44
static int rc_utimes(hctransaction_t trans, struct HCHead *);
44
static int rc_utimes(hctransaction_t trans, struct HCHead *);
45
static int rc_lutimes(hctransaction_t trans, struct HCHead *);
45
static int rc_geteuid(hctransaction_t trans, struct HCHead *);
46
static int rc_geteuid(hctransaction_t trans, struct HCHead *);
46
static int rc_getgroups(hctransaction_t trans, struct HCHead *);
47
static int rc_getgroups(hctransaction_t trans, struct HCHead *);
47
48
Lines 80-85 Link Here
80
    { HC_GETGROUPS,    rc_getgroups },
81
    { HC_GETGROUPS,    rc_getgroups },
81
    { HC_SCANDIR,      rc_scandir },
82
    { HC_SCANDIR,      rc_scandir },
82
    { HC_READFILE,     rc_readfile },
83
    { HC_READFILE,     rc_readfile },
84
    { HC_LUTIMES,      rc_lutimes },
83
};
85
};
84
86
85
static int chown_warning;
87
static int chown_warning;
Lines 1817-1822 Link Here
1817
    if (path == NULL)
1819
    if (path == NULL)
1818
       return(-2);
1820
       return(-2);
1819
    return(utimes(path, times));
1821
    return(utimes(path, times));
1822
}
1823
1824
/*
1825
 * LUTIMES
1826
 */
1827
int
1828
hc_lutimes(struct HostConf *hc, const char *path, const struct timeval *times)
1829
{
1830
    hctransaction_t trans;
1831
    struct HCHead *head;
1832
1833
    if (hc == NULL || hc->host == NULL)
1834
       return(lutimes(path, times));
1835
1836
    trans = hcc_start_command(hc, HC_LUTIMES);
1837
    hcc_leaf_string(trans, LC_PATH1, path);
1838
    hcc_leaf_int64(trans, LC_ATIME, times[0].tv_sec);
1839
    hcc_leaf_int64(trans, LC_MTIME, times[1].tv_sec);
1840
    if ((head = hcc_finish_command(trans)) == NULL)
1841
       return(-1);
1842
    if (head->error)
1843
       return(-1);
1844
    return(0);
1845
}
1846
1847
static int
1848
rc_lutimes(hctransaction_t trans, struct HCHead *head)
1849
{
1850
    struct HCLeaf *item;
1851
    struct timeval times[2];
1852
    const char *path;
1853
1854
    bzero(times, sizeof(times));
1855
    path = NULL;
1856
1857
    FOR_EACH_ITEM(item, trans, head) {
1858
       switch(item->leafid) {
1859
       case LC_PATH1:
1860
           path = HCC_STRING(item);
1861
           break;
1862
       case LC_ATIME:
1863
           times[0].tv_sec = HCC_INT64(item);
1864
           break;
1865
       case LC_MTIME:
1866
           times[1].tv_sec = HCC_INT64(item);
1867
           break;
1868
       }
1869
    }
1870
    if (ReadOnlyOpt) {
1871
       head->error = EACCES;
1872
       return (0);
1873
    }
1874
    if (path == NULL)
1875
       return(-2);
1876
    return(lutimes(path, times));
1820
}
1877
}
1821
1878
1822
uid_t
1879
uid_t
(-)hcproto.h 2020-12-18 11:35:30.786326000 +0100 (+2 lines)
Lines 39-44 Link Here
39
#define HC_GETGROUPS   0x0028
39
#define HC_GETGROUPS   0x0028
40
#define HC_SCANDIR     0x0029
40
#define HC_SCANDIR     0x0029
41
#define HC_READFILE    0x002A
41
#define HC_READFILE    0x002A
42
#define HC_LUTIMES     0x002B
42
43
43
#define LC_HELLOSTR    (0x0001|LCF_STRING)
44
#define LC_HELLOSTR    (0x0001|LCF_STRING)
44
#define LC_PATH1       (0x0010|LCF_STRING)
45
#define LC_PATH1       (0x0010|LCF_STRING)
Lines 111-116 Link Here
111
int hc_symlink(struct HostConf *hc, const char *name1, const char *name2);
112
int hc_symlink(struct HostConf *hc, const char *name1, const char *name2);
112
int hc_rename(struct HostConf *hc, const char *name1, const char *name2);
113
int hc_rename(struct HostConf *hc, const char *name1, const char *name2);
113
int hc_utimes(struct HostConf *hc, const char *path, const struct timeval *times);
114
int hc_utimes(struct HostConf *hc, const char *path, const struct timeval *times);
115
int hc_lutimes(struct HostConf *hc, const char *path, const struct timeval *times);
114
uid_t hc_geteuid(struct HostConf *hc);
116
uid_t hc_geteuid(struct HostConf *hc);
115
int hc_getgroups(struct HostConf *hc, gid_t **gidlist);
117
int hc_getgroups(struct HostConf *hc, gid_t **gidlist);

Return to bug 252854