Archive-xattr-Patch
All checks were successful
Source release / source-package (push) Successful in 41s
All checks were successful
Source release / source-package (push) Successful in 41s
This commit is contained in:
@@ -65,6 +65,7 @@ option(ENABLE_DEBUG_DOSUTILS "Should we build with Mars Nwe Dosutils Debugging?"
|
||||
option(ENABLE_INTERNAL_RIP_SAP "Should we build Mars Nwe with Internal Router?" ON)
|
||||
option(ENABLE_SHADOW_PWD "Should we build Mars Nwe with Shadow Password Support?" ON)
|
||||
option(ENABLE_QUOTA_SUPPORT "Should we build Mars Nwe with Quota Support?" OFF)
|
||||
option(ENABLE_XATTR "Should we build Mars Nwe with extended attribute support?" ON)
|
||||
option(MARS_NWE_INSTALL_DOSUTILS "Install DOS client utilities" ON)
|
||||
option(MARS_NWE_INSTALL_NEW_DOSUTILS "Install the new/experimental DOS client utilities instead of legacy netold.exe" OFF)
|
||||
option(MARS_NWE_BUILD_DOSUTILS "Build DOS client utilities with Open Watcom" OFF)
|
||||
@@ -101,6 +102,13 @@ ELSE (ENABLE_QUOTA_SUPPORT)
|
||||
SET (MARS_NWE_QUOTA_SUPPORT "0")
|
||||
ENDIF (ENABLE_QUOTA_SUPPORT)
|
||||
|
||||
find_package(XAttr QUIET)
|
||||
IF (ENABLE_XATTR AND XATTR_FOUND)
|
||||
SET (MARS_NWE_XATTR_SUPPORT "1")
|
||||
ELSE (ENABLE_XATTR AND XATTR_FOUND)
|
||||
SET (MARS_NWE_XATTR_SUPPORT "0")
|
||||
ENDIF (ENABLE_XATTR AND XATTR_FOUND)
|
||||
|
||||
IF (NOT MAX_CONNECTIONS)
|
||||
SET (MAX_CONNECTIONS "50")
|
||||
ENDIF (NOT MAX_CONNECTIONS)
|
||||
@@ -120,6 +128,12 @@ find_package(OpenSSL REQUIRED)
|
||||
find_package(PAM REQUIRED)
|
||||
find_package(DL REQUIRED)
|
||||
|
||||
if(MARS_NWE_XATTR_SUPPORT)
|
||||
message(STATUS "XAttr support: enabled")
|
||||
else()
|
||||
message(STATUS "XAttr support: disabled")
|
||||
endif()
|
||||
|
||||
# we want to use systemd, if possible
|
||||
set(SYSTEMD_SERVICES_INSTALL_DIR "" CACHE PATH "Directory for systemd service files")
|
||||
INCLUDE(${CMAKE_MODULE_PATH}/systemdservice.cmake)
|
||||
|
||||
58
cmake/modules/FindXAttr.cmake
Normal file
58
cmake/modules/FindXAttr.cmake
Normal file
@@ -0,0 +1,58 @@
|
||||
# - Find Linux extended attribute support
|
||||
#
|
||||
# This module sets:
|
||||
# XATTR_FOUND - true if getxattr/setxattr are available
|
||||
# XATTR_LIBRARIES - libraries needed for xattr functions, if any
|
||||
#
|
||||
# Modern glibc exposes getxattr/setxattr from libc. Older systems may
|
||||
# require libattr, so check libc first and then retry with -lattr.
|
||||
|
||||
include(CheckIncludeFile)
|
||||
include(CheckSymbolExists)
|
||||
|
||||
set(XATTR_FOUND FALSE)
|
||||
set(XATTR_LIBRARIES "")
|
||||
|
||||
check_include_file("sys/xattr.h" XATTR_HAVE_SYS_XATTR_H)
|
||||
|
||||
if(XATTR_HAVE_SYS_XATTR_H)
|
||||
check_symbol_exists(getxattr "sys/types.h;sys/xattr.h" XATTR_HAVE_GETXATTR)
|
||||
check_symbol_exists(setxattr "sys/types.h;sys/xattr.h" XATTR_HAVE_SETXATTR)
|
||||
|
||||
if(XATTR_HAVE_GETXATTR AND XATTR_HAVE_SETXATTR)
|
||||
set(XATTR_FOUND TRUE)
|
||||
else()
|
||||
find_library(XATTR_ATTR_LIBRARY attr)
|
||||
if(XATTR_ATTR_LIBRARY)
|
||||
set(_XATTR_SAVE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${XATTR_ATTR_LIBRARY}")
|
||||
check_symbol_exists(getxattr "sys/types.h;sys/xattr.h" XATTR_HAVE_GETXATTR_ATTR)
|
||||
check_symbol_exists(setxattr "sys/types.h;sys/xattr.h" XATTR_HAVE_SETXATTR_ATTR)
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${_XATTR_SAVE_REQUIRED_LIBRARIES}")
|
||||
|
||||
if(XATTR_HAVE_GETXATTR_ATTR AND XATTR_HAVE_SETXATTR_ATTR)
|
||||
set(XATTR_FOUND TRUE)
|
||||
set(XATTR_LIBRARIES "${XATTR_ATTR_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(XATTR_FOUND)
|
||||
if(XATTR_LIBRARIES)
|
||||
message(STATUS "Found XAttr: ${XATTR_LIBRARIES}")
|
||||
else()
|
||||
message(STATUS "Found XAttr: libc")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Could NOT find XAttr")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
XATTR_ATTR_LIBRARY
|
||||
XATTR_HAVE_SYS_XATTR_H
|
||||
XATTR_HAVE_GETXATTR
|
||||
XATTR_HAVE_SETXATTR
|
||||
XATTR_HAVE_GETXATTR_ATTR
|
||||
XATTR_HAVE_SETXATTR_ATTR
|
||||
)
|
||||
@@ -95,6 +95,8 @@
|
||||
/* change to '1' for shadow passwds */
|
||||
#define QUOTA_SUPPORT @MARS_NWE_QUOTA_SUPPORT@
|
||||
/* change to '1' for quota support */
|
||||
#define XATTR_SUPPORT @MARS_NWE_XATTR_SUPPORT@
|
||||
/* change to '1' for Linux xattr support */
|
||||
|
||||
/* for sending 'Request being serviced' replys, /lenz */
|
||||
#define CALL_NWCONN_OVER_SOCKET 0
|
||||
|
||||
22
include/nwarchive.h
Normal file
22
include/nwarchive.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/* nwarchive.h - mars_nwe private archive metadata helpers */
|
||||
#ifndef _NWARCHIVE_H_
|
||||
#define _NWARCHIVE_H_
|
||||
|
||||
#include "net.h"
|
||||
|
||||
#define MARS_NWE_ARCHIVE_HAS_DATE 0x01
|
||||
#define MARS_NWE_ARCHIVE_HAS_TIME 0x02
|
||||
#define MARS_NWE_ARCHIVE_HAS_ARCHIVER 0x04
|
||||
|
||||
void mars_nwe_get_archive_info(char *unixname,
|
||||
uint16 *archive_date,
|
||||
uint16 *archive_time,
|
||||
uint32 *archiver_id,
|
||||
uint8 *flags);
|
||||
|
||||
int mars_nwe_set_archive_info(char *unixname,
|
||||
int set_date, uint16 archive_date,
|
||||
int set_time, uint16 archive_time,
|
||||
int set_archiver, uint32 archiver_id);
|
||||
|
||||
#endif
|
||||
@@ -57,7 +57,7 @@ ELSE(ENABLE_INTERNAL_RIP_SAP)
|
||||
ENDIF(ENABLE_INTERNAL_RIP_SAP)
|
||||
|
||||
add_executable(nwserv nwserv.c net1.c tools.c ${EMUTLI} ${EMUTLI1} ${NWROUTE_0} )
|
||||
add_executable(nwconn nwconn.c net1.c tools.c connect.c namspace.c nwvolume.c nwfile.c unxfile.c nwqconn.c nameos2.c namedos.c nwfname.c nwshare.c extpipe.c nwattrib.c trustee.c ${EMUTLI} )
|
||||
add_executable(nwconn nwconn.c net1.c tools.c connect.c namspace.c nwvolume.c nwfile.c unxfile.c nwqconn.c nameos2.c namedos.c nwfname.c nwshare.c extpipe.c nwattrib.c trustee.c nwarchive.c ${EMUTLI} )
|
||||
add_executable(ncpserv ncpserv.c net1.c tools.c ${EMUTLI} )
|
||||
add_executable(nwclient nwclient.c net1.c tools.c ${EMUTLI} )
|
||||
add_executable(nwbind nwbind.c net1.c tools.c nwdbm.c nwcrypt.c unxlog.c sema.c nwqueue.c unxfile.c ${EMUTLI} )
|
||||
@@ -73,7 +73,7 @@ add_executable(ftrustee ftrustee.c tools.c nwfname.c unxfile.c nwvolume.c nwattr
|
||||
##############
|
||||
|
||||
target_link_libraries(nwserv ${CRYPT_LIBRARIES} )
|
||||
target_link_libraries(nwconn ${CRYPT_LIBRARIES} )
|
||||
target_link_libraries(nwconn ${CRYPT_LIBRARIES} ${XATTR_LIBRARIES} )
|
||||
target_link_libraries(ncpserv ${CRYPT_LIBRARIES} )
|
||||
target_link_libraries(nwclient ${CRYPT_LIBRARIES} )
|
||||
target_link_libraries(nwbind ${CRYPT_LIBRARIES} ${GDBM_LIBRARIES} )
|
||||
|
||||
@@ -54,6 +54,7 @@ static int act_umode_file=0;
|
||||
#include "nwvolume.h"
|
||||
#include "nwshare.h"
|
||||
#include "nwattrib.h"
|
||||
#include "nwarchive.h"
|
||||
#include "trustee.h"
|
||||
#include "nwfile.h"
|
||||
#include "nwconn.h"
|
||||
@@ -1277,11 +1278,16 @@ static time_t nw_2_un_time_parts(uint16 xdate, uint16 xtime)
|
||||
return(mktime(&s_tm));
|
||||
}
|
||||
|
||||
#define DM_ARCHIVE_DATE 0x0020UL
|
||||
#define DM_ARCHIVE_TIME 0x0040UL
|
||||
#define DM_ARCHIVER_ID 0x0080UL
|
||||
#define DM_MODIFY_DATE 0x0100UL
|
||||
#define DM_MODIFY_TIME 0x0200UL
|
||||
#define DM_LAST_ACCESS_DATE 0x0800UL
|
||||
#define DM_NCP22_25_TIME_BITS \
|
||||
(DM_MODIFY_DATE | DM_MODIFY_TIME | DM_LAST_ACCESS_DATE)
|
||||
#define DM_NCP22_25_ARCHIVE_BITS \
|
||||
(DM_ARCHIVE_DATE | DM_ARCHIVE_TIME | DM_ARCHIVER_ID)
|
||||
|
||||
static int set_ncp22_25_times(int volume, char *unixname, struct stat *stb,
|
||||
NW_SET_DIR_INFO *f, uint32 change_mask,
|
||||
@@ -1342,6 +1348,40 @@ static int set_ncp22_25_times(int volume, char *unixname, struct stat *stb,
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int set_ncp22_25_archive_info(char *unixname,
|
||||
NW_SET_DIR_INFO *f,
|
||||
uint32 change_mask,
|
||||
int is_dir)
|
||||
{
|
||||
uint16 adate = 0;
|
||||
uint16 atime = 0;
|
||||
uint32 aid = 0;
|
||||
|
||||
if (!(change_mask & DM_NCP22_25_ARCHIVE_BITS))
|
||||
return(0);
|
||||
|
||||
if (is_dir) {
|
||||
if (change_mask & DM_ARCHIVE_DATE)
|
||||
adate = (uint16)GET_16(f->u.d.archived.date);
|
||||
if (change_mask & DM_ARCHIVE_TIME)
|
||||
atime = (uint16)GET_16(f->u.d.archived.time);
|
||||
if (change_mask & DM_ARCHIVER_ID)
|
||||
aid = GET_BE32(f->u.d.archived.id);
|
||||
} else {
|
||||
if (change_mask & DM_ARCHIVE_DATE)
|
||||
adate = (uint16)GET_16(f->u.f.archived.date);
|
||||
if (change_mask & DM_ARCHIVE_TIME)
|
||||
atime = (uint16)GET_16(f->u.f.archived.time);
|
||||
if (change_mask & DM_ARCHIVER_ID)
|
||||
aid = GET_BE32(f->u.f.archived.id);
|
||||
}
|
||||
|
||||
return(mars_nwe_set_archive_info(unixname,
|
||||
!!(change_mask & DM_ARCHIVE_DATE), adate,
|
||||
!!(change_mask & DM_ARCHIVE_TIME), atime,
|
||||
!!(change_mask & DM_ARCHIVER_ID), aid));
|
||||
}
|
||||
|
||||
static int get_file_attrib(NW_FILE_INFO *f, char *unixname, struct stat *stb,
|
||||
NW_PATH *nwpath)
|
||||
{
|
||||
@@ -2861,6 +2901,17 @@ void get_dos_file_attrib(NW_DOS_FILE_INFO *f,
|
||||
un_time_2_nw(stb->st_mtime, f->created.time, 0);
|
||||
U32_TO_BE32(nw_owner, f->created.id);
|
||||
|
||||
{
|
||||
uint16 archive_date = 0;
|
||||
uint16 archive_time = 0;
|
||||
uint32 archiver_id = 0;
|
||||
mars_nwe_get_archive_info(unixname, &archive_date, &archive_time,
|
||||
&archiver_id, NULL);
|
||||
U16_TO_16(archive_date, f->archived.date);
|
||||
U16_TO_16(archive_time, f->archived.time);
|
||||
U32_TO_BE32(archiver_id, f->archived.id);
|
||||
}
|
||||
|
||||
un_date_2_nw(stb->st_mtime, f->updated.date, 0);
|
||||
un_time_2_nw(stb->st_mtime, f->updated.time, 0);
|
||||
U32_TO_BE32(nw_owner, f->updated.id);
|
||||
@@ -2888,6 +2939,16 @@ void get_dos_dir_attrib(NW_DOS_DIR_INFO *f,
|
||||
un_date_2_nw(stb->st_mtime, f->created.date,0);
|
||||
un_time_2_nw(stb->st_mtime, f->created.time,0);
|
||||
U32_TO_BE32(get_file_owner(stb), f->created.id);
|
||||
{
|
||||
uint16 archive_date = 0;
|
||||
uint16 archive_time = 0;
|
||||
uint32 archiver_id = 0;
|
||||
mars_nwe_get_archive_info(unixname, &archive_date, &archive_time,
|
||||
&archiver_id, NULL);
|
||||
U16_TO_16(archive_date, f->archived.date);
|
||||
U16_TO_16(archive_time, f->archived.time);
|
||||
U32_TO_BE32(archiver_id, f->archived.id);
|
||||
}
|
||||
un_date_2_nw(stb->st_mtime, f->modify_date, 0);
|
||||
un_time_2_nw(stb->st_mtime, f->modify_time, 0);
|
||||
U32_TO_BE32(MAX_U32, f->max_space);
|
||||
@@ -2995,6 +3056,10 @@ int nw_set_a_directory_entry(int dirhandle,
|
||||
else if (change_mask & DM_NCP22_25_TIME_BITS)
|
||||
s_stat(unixname, &stbuff, NULL);
|
||||
}
|
||||
if (!completition) {
|
||||
completition=set_ncp22_25_archive_info(unixname, f, change_mask,
|
||||
S_ISDIR(stbuff.st_mode));
|
||||
}
|
||||
if (S_ISDIR(stbuff.st_mode)) {
|
||||
if (change_mask & 0x1000) {
|
||||
int result=tru_set_inherited_mask(nwpath.volume, unixname,
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "nwvolume.h"
|
||||
#include "connect.h"
|
||||
#include "nwattrib.h"
|
||||
#include "nwarchive.h"
|
||||
#include "trustee.h"
|
||||
#include "nwconn.h"
|
||||
#include "nwfile.h"
|
||||
@@ -1115,11 +1116,16 @@ static int build_dir_info(DIR_BASE_ENTRY *dbe,
|
||||
} else p+=10;
|
||||
|
||||
if (infomask & INFO_MSK_ARCHIVE_INFO) {
|
||||
un_time_2_nw(0, p, 0);
|
||||
uint16 archive_date = 0;
|
||||
uint16 archive_time = 0;
|
||||
uint32 archiver_id = 0;
|
||||
mars_nwe_get_archive_info(unixname, &archive_date, &archive_time,
|
||||
&archiver_id, NULL);
|
||||
U16_TO_16(archive_time, p);
|
||||
p +=2;
|
||||
un_date_2_nw(0, p, 0);
|
||||
U16_TO_16(archive_date, p);
|
||||
p +=2;
|
||||
U32_TO_BE32(0, p); /* HI-LOW */
|
||||
U32_TO_BE32(archiver_id, p); /* HI-LOW */
|
||||
p +=4;
|
||||
} else p+=8;
|
||||
|
||||
|
||||
126
src/nwarchive.c
Normal file
126
src/nwarchive.c
Normal file
@@ -0,0 +1,126 @@
|
||||
/* nwarchive.c - mars_nwe private archive metadata helpers */
|
||||
#include "net.h"
|
||||
#include "nwarchive.h"
|
||||
|
||||
#if XATTR_SUPPORT
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/xattr.h>
|
||||
#endif
|
||||
|
||||
#define MARS_NWE_ARCHIVE_XATTR "user.mars_nwe.archive"
|
||||
#define MARS_NWE_ARCHIVE_VERSION 1
|
||||
|
||||
typedef struct {
|
||||
uint8 version;
|
||||
uint8 flags;
|
||||
uint8 archive_date[2];
|
||||
uint8 archive_time[2];
|
||||
uint8 archiver_id[4];
|
||||
} MARS_NWE_ARCHIVE_XATTR_DATA;
|
||||
|
||||
static void init_archive_data(MARS_NWE_ARCHIVE_XATTR_DATA *d)
|
||||
{
|
||||
memset(d, 0, sizeof(*d));
|
||||
d->version = MARS_NWE_ARCHIVE_VERSION;
|
||||
}
|
||||
|
||||
static void read_archive_data(MARS_NWE_ARCHIVE_XATTR_DATA *d,
|
||||
uint16 *archive_date,
|
||||
uint16 *archive_time,
|
||||
uint32 *archiver_id,
|
||||
uint8 *flags)
|
||||
{
|
||||
if (flags)
|
||||
*flags = d->flags;
|
||||
if (archive_date)
|
||||
*archive_date = (d->flags & MARS_NWE_ARCHIVE_HAS_DATE)
|
||||
? (uint16)GET_16(d->archive_date) : 0;
|
||||
if (archive_time)
|
||||
*archive_time = (d->flags & MARS_NWE_ARCHIVE_HAS_TIME)
|
||||
? (uint16)GET_16(d->archive_time) : 0;
|
||||
if (archiver_id)
|
||||
*archiver_id = (d->flags & MARS_NWE_ARCHIVE_HAS_ARCHIVER)
|
||||
? GET_BE32(d->archiver_id) : 0;
|
||||
}
|
||||
|
||||
#if XATTR_SUPPORT
|
||||
static int get_archive_data(char *unixname, MARS_NWE_ARCHIVE_XATTR_DATA *d)
|
||||
{
|
||||
ssize_t len;
|
||||
|
||||
init_archive_data(d);
|
||||
if (!unixname || !*unixname)
|
||||
return(-1);
|
||||
|
||||
len = getxattr(unixname, MARS_NWE_ARCHIVE_XATTR, d, sizeof(*d));
|
||||
if (len != sizeof(*d) || d->version != MARS_NWE_ARCHIVE_VERSION) {
|
||||
init_archive_data(d);
|
||||
return(-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void mars_nwe_get_archive_info(char *unixname,
|
||||
uint16 *archive_date,
|
||||
uint16 *archive_time,
|
||||
uint32 *archiver_id,
|
||||
uint8 *flags)
|
||||
{
|
||||
MARS_NWE_ARCHIVE_XATTR_DATA d;
|
||||
|
||||
#if XATTR_SUPPORT
|
||||
(void)get_archive_data(unixname, &d);
|
||||
#else
|
||||
(void)unixname;
|
||||
init_archive_data(&d);
|
||||
#endif
|
||||
read_archive_data(&d, archive_date, archive_time, archiver_id, flags);
|
||||
}
|
||||
|
||||
int mars_nwe_set_archive_info(char *unixname,
|
||||
int set_date, uint16 archive_date,
|
||||
int set_time, uint16 archive_time,
|
||||
int set_archiver, uint32 archiver_id)
|
||||
{
|
||||
#if XATTR_SUPPORT
|
||||
MARS_NWE_ARCHIVE_XATTR_DATA d;
|
||||
|
||||
(void)get_archive_data(unixname, &d);
|
||||
|
||||
if (set_date) {
|
||||
U16_TO_16(archive_date, d.archive_date);
|
||||
d.flags |= MARS_NWE_ARCHIVE_HAS_DATE;
|
||||
}
|
||||
if (set_time) {
|
||||
U16_TO_16(archive_time, d.archive_time);
|
||||
d.flags |= MARS_NWE_ARCHIVE_HAS_TIME;
|
||||
}
|
||||
if (set_archiver) {
|
||||
U32_TO_BE32(archiver_id, d.archiver_id);
|
||||
d.flags |= MARS_NWE_ARCHIVE_HAS_ARCHIVER;
|
||||
}
|
||||
|
||||
if (!unixname || !*unixname)
|
||||
return(0);
|
||||
|
||||
if (setxattr(unixname, MARS_NWE_ARCHIVE_XATTR, &d, sizeof(d), 0)) {
|
||||
int err = errno;
|
||||
/* Compatibility rule: NetWare archive metadata has no POSIX field.
|
||||
* If Linux xattrs are unavailable or rejected, keep the NCP call
|
||||
* successful and only log that the extra metadata was not stored.
|
||||
*/
|
||||
XDPRINTF((5,0,"mars_nwe archive xattr ignored for %s errno=%d", unixname, err));
|
||||
}
|
||||
#else
|
||||
(void)unixname;
|
||||
(void)set_date;
|
||||
(void)archive_date;
|
||||
(void)set_time;
|
||||
(void)archive_time;
|
||||
(void)set_archiver;
|
||||
(void)archiver_id;
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
Reference in New Issue
Block a user