typedef typename boost::call_traits<Tp>::const_reference const_reference;
typedef Tp value_type;
typedef typename boost::call_traits<Tp>::value_type result_type;
- using dispose_param_type = std::conditional_t< std::is_pointer_v<Tp> || std::is_integral_v<Tp>, Tp const, reference >;
+ // bsc#1194597: Header is exposed in the public API, so it must be c++11:
+ // using dispose_param_type = std::conditional_t< std::is_pointer_v<Tp> || std::is_integral_v<Tp>, Tp const, reference >;
+ using dispose_param_type = typename std::conditional< std::is_pointer<Tp>::value || std::is_integral<Tp>::value, Tp const, reference >::type;
public:
/** Dispose function signatue. */
// get from /etc/zypp/credentials.d, delete the leading path
credfile = _options.customCredFileDir / file.basename();
- // make sure only our thread accesses the file
- bpci::file_lock lockFile ( credfile.c_str() );
- bpci::scoped_lock lock( lockFile );
+ PathInfo pi { credfile };
+ if ( pi.userMayR() ) try {
+ // make sure only our thread accesses the file
+ bpci::file_lock lockFile ( credfile.c_str() );
+ bpci::scoped_lock lock( lockFile );
+
+ CredentialFileReader(credfile, bind(&Impl::processCredentials, this, _1));
+ }
+ catch ( ... ) {
+ WAR << pi << " failed to lock file for reading." << endl;
+ }
- CredentialFileReader(credfile, bind(&Impl::processCredentials, this, _1));
if (_credsTmp.empty())
- WAR << file << " does not contain valid credentials or is not readable." << endl;
+ WAR << pi << " does not contain valid credentials or is not readable." << endl;
else
{
result = *_credsTmp.begin();
const mode_t mode)
{
int ret = 0;
- filesystem::assert_dir(file.dirname());
+ filesystem::assert_file_mode( file, mode );
- std::ofstream fs(file.c_str());
- if (!fs)
- ret = 1;
+ PathInfo pi { file };
+ if ( pi.userMayRW() ) try {
+ // make sure only our thread accesses the file
+ bpci::file_lock lockFile ( file.c_str() );
+ bpci::scoped_lock lock( lockFile );
- // make sure only our thread accesses the file
- bpci::file_lock lockFile ( file.c_str() );
- bpci::scoped_lock lock( lockFile );
-
-
- for_(it, creds.begin(), creds.end())
- {
- (*it)->dumpAsIniOn(fs);
- (*it)->setLastDatabaseUpdate( time( nullptr ) );
- fs << endl;
+ std::ofstream fs(file.c_str());
+ for_(it, creds.begin(), creds.end())
+ {
+ (*it)->dumpAsIniOn(fs);
+ (*it)->setLastDatabaseUpdate( time( nullptr ) );
+ fs << endl;
+ }
+ if ( !fs ) {
+ WAR << pi << " failed to write credentials to file." << endl;
+ ret = 1;
+ }
+ fs.close();
+ }
+ catch ( ... ) {
+ WAR << pi << " failed to lock file for writing." << endl;
+ ret = 1;
}
- fs.close();
-
- filesystem::chmod(file, mode);
return ret;
}