@@ -320,7 +320,6 @@ XrdMgmOfs::XrdMgmOfs(XrdSysError* ep):
320320{
321321 eDest = ep;
322322 ConfigFN = 0 ;
323- enforceRecycleBin = false ;
324323
325324 if (getenv (" EOS_MGM_HTTP_PORT" )) {
326325 mHttpdPort = strtol (getenv (" EOS_MGM_HTTP_PORT" ), 0 , 10 );
@@ -374,9 +373,14 @@ XrdMgmOfs::XrdMgmOfs(XrdSysError* ep):
374373 {
375374 const char * am = getenv (" EOS_MGM_AUDIT" );
376375 std::string mode = (am ? am : " " );
376+
377377 // normalize to lowercase
378- for (auto & c : mode) c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
379- if (mode.empty () || mode == " none" || mode == " false" || mode == " no" || mode == " off" ) {
378+ for (auto & c : mode) {
379+ c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
380+ }
381+
382+ if (mode.empty () || mode == " none" || mode == " false" || mode == " no" ||
383+ mode == " off" ) {
380384 mEnvAuditDisableAll = true ;
381385 mEnvAuditAttributeMode = false ;
382386 mEnvAuditAttributeOnly = false ;
@@ -415,27 +419,33 @@ XrdMgmOfs::XrdMgmOfs(XrdSysError* ep):
415419 }
416420
417421 const char * rs = getenv (" EOS_MGM_AUDIT_READ_SUFFIX" );
422+
418423 if (rs && *rs) {
419424 std::string s = rs;
420425 std::string token;
426+
421427 for (size_t i = 0 ; i <= s.size (); ++i) {
422428 if (i == s.size () || s[i] == ' ,' || s[i] == ' ;' || s[i] == ' ' ) {
423429 if (!token.empty ()) {
424430 // normalize
425431 for (auto & c : token) c = static_cast <char >(
426- std::tolower (static_cast <unsigned char >(c)));
427- if (!token.empty () && token[0 ] == ' .' ) token.erase (token.begin ());
432+ std::tolower (static_cast <unsigned char >(c)));
433+
434+ if (!token.empty () && token[0 ] == ' .' ) {
435+ token.erase (token.begin ());
436+ }
437+
428438 mEnvAuditReadSuffixes .push_back (token);
429439 token.clear ();
430440 }
431441 } else {
432442 token.push_back (s[i]);
433443 }
434444 }
445+
435446 mEnvAuditReadSuffixesSet = true ;
436447 }
437448 }
438-
439449 EgroupRefresh.reset (new eos::mgm::Egroup ());
440450 mRecycler .reset (new eos::mgm::Recycle ());
441451 mDeviceTracker .reset (new eos::mgm::Devices ());
@@ -1805,98 +1815,193 @@ XrdMgmOfs::IsMaster(const char* path,
18051815bool
18061816XrdMgmOfs::AllowAuditModification (const std::string& path)
18071817{
1808- if (!mAudit ) return false ;
1809- if (!mEnvAuditAttributeOnly ) return true ;
1818+ if (!mAudit ) {
1819+ return false ;
1820+ }
1821+
1822+ if (!mEnvAuditAttributeOnly ) {
1823+ return true ;
1824+ }
1825+
18101826 // attribute-only: parent sys.audit must enable modifications
18111827 std::string pdir;
1812- { eos::common::Path cP (path.c_str ()); pdir = cP.GetParentPath (); }
1828+ {
1829+ eos::common::Path cP (path.c_str ());
1830+ pdir = cP.GetParentPath ();
1831+ }
1832+
18131833 try {
18141834 auto pd = eosView->getContainer (pdir);
18151835 eos::MDLocking::ContainerReadLock cmd_lock (pd.get ());
18161836 auto amap = pd->getAttributes ();
18171837 auto it = amap.find (" sys.audit" );
1838+
18181839 if (it != amap.end ()) {
18191840 std::string mode = it->second ;
1820- for (auto & c : mode) c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
1821- if (mode == " all" || mode == " detail" || mode == " default" || mode == " modifications" ) return true ;
1841+
1842+ for (auto & c : mode) {
1843+ c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
1844+ }
1845+
1846+ if (mode == " all" || mode == " detail" || mode == " default" ||
1847+ mode == " modifications" ) {
1848+ return true ;
1849+ }
18221850 }
18231851 } catch (...) {}
1852+
18241853 return false ;
18251854}
18261855
18271856bool
18281857XrdMgmOfs::AllowAuditList (const std::string& dirPath)
18291858{
1830- if (!mAudit ) return false ;
1831- if (!mEnvAuditAttributeOnly ) return mAudit ->isListAuditingEnabled ();
1859+ if (!mAudit ) {
1860+ return false ;
1861+ }
1862+
1863+ if (!mEnvAuditAttributeOnly ) {
1864+ return mAudit ->isListAuditingEnabled ();
1865+ }
1866+
18321867 // attribute-only: dir sys.audit must be 'all'
18331868 try {
18341869 auto dh = eosView->getContainer (dirPath);
18351870 eos::MDLocking::ContainerReadLock cmd_lock (dh.get ());
18361871 auto amap = dh->getAttributes ();
18371872 auto it = amap.find (" sys.audit" );
1873+
18381874 if (it != amap.end ()) {
18391875 std::string mode = it->second ;
1840- for (auto & c : mode) c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
1841- if (mode == " all" ) return true ;
1876+
1877+ for (auto & c : mode) {
1878+ c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
1879+ }
1880+
1881+ if (mode == " all" ) {
1882+ return true ;
1883+ }
18421884 }
18431885 } catch (...) {}
1886+
18441887 return false ;
18451888}
18461889
18471890bool
18481891XrdMgmOfs::AllowAuditRead (const std::string& path)
18491892{
1850- if (!mAudit ) return false ;
1851- if (!mEnvAuditAttributeOnly ) return (mAudit ->isReadAuditingEnabled () && mAudit ->shouldAuditReadPath (path));
1893+ if (!mAudit ) {
1894+ return false ;
1895+ }
1896+
1897+ if (!mEnvAuditAttributeOnly ) {
1898+ return (mAudit ->isReadAuditingEnabled () && mAudit ->shouldAuditReadPath (path));
1899+ }
1900+
18521901 // attribute-only: parent sys.audit governs; default/detail/all enable; default uses suffix filter
18531902 std::string pdir;
1854- { eos::common::Path cP (path.c_str ()); pdir = cP.GetParentPath (); }
1903+ {
1904+ eos::common::Path cP (path.c_str ());
1905+ pdir = cP.GetParentPath ();
1906+ }
1907+
18551908 try {
18561909 auto pd = eosView->getContainer (pdir);
18571910 eos::MDLocking::ContainerReadLock cmd_lock (pd.get ());
18581911 auto amap = pd->getAttributes ();
18591912 auto it = amap.find (" sys.audit" );
1913+
18601914 if (it != amap.end ()) {
18611915 std::string mode = it->second ;
1862- for (auto & c : mode) c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
1863- if (mode == " detail" || mode == " all" ) return true ;
1864- if (mode == " default" ) return mAudit ->shouldAuditReadPath (path);
1916+
1917+ for (auto & c : mode) {
1918+ c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
1919+ }
1920+
1921+ if (mode == " detail" || mode == " all" ) {
1922+ return true ;
1923+ }
1924+
1925+ if (mode == " default" ) {
1926+ return mAudit ->shouldAuditReadPath (path);
1927+ }
18651928 }
18661929 } catch (...) {}
1930+
18671931 return false ;
18681932}
18691933
18701934// Fast-path overloads that use an already available sys.audit attribute value
18711935bool
18721936XrdMgmOfs::AllowAuditModificationAttr (const std::string& auditMode)
18731937{
1874- if (!mAudit ) return false ;
1875- if (!mEnvAuditAttributeOnly ) return true ;
1938+ if (!mAudit ) {
1939+ return false ;
1940+ }
1941+
1942+ if (!mEnvAuditAttributeOnly ) {
1943+ return true ;
1944+ }
1945+
18761946 std::string mode = auditMode;
1877- for (auto & c : mode) c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
1878- if (mode == " all" || mode == " detail" || mode == " default" || mode == " modifications" ) return true ;
1947+
1948+ for (auto & c : mode) {
1949+ c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
1950+ }
1951+
1952+ if (mode == " all" || mode == " detail" || mode == " default" ||
1953+ mode == " modifications" ) {
1954+ return true ;
1955+ }
1956+
18791957 return false ;
18801958}
18811959
18821960bool
18831961XrdMgmOfs::AllowAuditListAttr (const std::string& auditMode)
18841962{
1885- if (!mAudit ) return false ;
1886- if (!mEnvAuditAttributeOnly ) return mAudit ->isListAuditingEnabled ();
1963+ if (!mAudit ) {
1964+ return false ;
1965+ }
1966+
1967+ if (!mEnvAuditAttributeOnly ) {
1968+ return mAudit ->isListAuditingEnabled ();
1969+ }
1970+
18871971 std::string mode = auditMode;
1888- for (auto & c : mode) c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
1972+
1973+ for (auto & c : mode) {
1974+ c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
1975+ }
1976+
18891977 return (mode == " all" );
18901978}
18911979
18921980bool
1893- XrdMgmOfs::AllowAuditReadAttr (const std::string& auditMode, const std::string& path)
1981+ XrdMgmOfs::AllowAuditReadAttr (const std::string& auditMode,
1982+ const std::string& path)
18941983{
1895- if (!mAudit ) return false ;
1896- if (!mEnvAuditAttributeOnly ) return (mAudit ->isReadAuditingEnabled () && mAudit ->shouldAuditReadPath (path));
1984+ if (!mAudit ) {
1985+ return false ;
1986+ }
1987+
1988+ if (!mEnvAuditAttributeOnly ) {
1989+ return (mAudit ->isReadAuditingEnabled () && mAudit ->shouldAuditReadPath (path));
1990+ }
1991+
18971992 std::string mode = auditMode;
1898- for (auto & c : mode) c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
1899- if (mode == " detail" || mode == " all" ) return true ;
1900- if (mode == " default" ) return mAudit ->shouldAuditReadPath (path);
1993+
1994+ for (auto & c : mode) {
1995+ c = static_cast <char >(std::tolower (static_cast <unsigned char >(c)));
1996+ }
1997+
1998+ if (mode == " detail" || mode == " all" ) {
1999+ return true ;
2000+ }
2001+
2002+ if (mode == " default" ) {
2003+ return mAudit ->shouldAuditReadPath (path);
2004+ }
2005+
19012006 return false ;
19022007}
0 commit comments