Hi everyone, today, when I was doing another test of my package manager, I faced this error:
Failed to set the owner uid:root and gid:root at the path /mnt/ism/usr
#<File::BadPatternError:Invalid character set: unterminated character set>
The call is from this portion of code:
@@changeOwnerDirs.each do |dir|
setOwnerRecursively("#{Ism.settings.rootPath}#{dir}","root","root")
end
The value of the array (fail at the first entry):
@@changeOwnerDirs = [ "/usr","/lib","/lib64","/var","/etc","/bin","/sbin","/tmp","/boot","#{ISM::Default::Path::ToolsDirectory}","#{ISM::Default::Path::SourcesDirectory}","/.","/.."]
And the implementation of my function setOwnerRecursively:
def setOwner(path : String, uid : Int | String, gid : Int | String)
begin
File.chown( path,
(uid.is_a?(String) ? System::Group.find_by(name: uid).id : uid).to_i,
(gid.is_a?(String) ? System::Group.find_by(name: gid).id : gid).to_i)
rescue error
Ism.notifyOfSetOwnerError(path, uid, gid, error)
Ism.exitProgram
end
end
def setOwnerRecursively(path : String, uid : Int | String, gid : Int | String)
begin
Dir.glob(Dir["#{path}/**/*"]) do |file_path|
setOwner(path, uid, gid)
end
rescue error
Ism.notifyOfSetOwnerRecursivelyError(path, uid, gid, error)
Ism.exitProgram
end
end
Any idea ? Because I don’t see where this problem come from to be honest.