mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-19 11:22:55 +09:00
Bug #1119: This old bug can now be confirmed and fixed with fsck
(cherry picked from commit 74091c3153)
This commit is contained in:
1 parent
d831fca9f0
commit
bf361e7c63
1 file changed
+18
-6
+18
-6
@@ -170,14 +170,17 @@ module OneDBFsck
|
||||
|
||||
users_fix = {}
|
||||
|
||||
@db.fetch("SELECT oid,body FROM user_pool") do |row|
|
||||
@db.fetch("SELECT oid,body,gid FROM user_pool") do |row|
|
||||
doc = Document.new(row[:body])
|
||||
|
||||
gid = doc.root.get_text('GID').to_s.to_i
|
||||
user_gid = gid
|
||||
|
||||
if group[gid].nil?
|
||||
log_error("User #{row[:oid]} is in group #{gid}, but it does not exist")
|
||||
|
||||
user_gid = 1
|
||||
|
||||
doc.root.each_element('GID') do |e|
|
||||
e.text = "1"
|
||||
end
|
||||
@@ -186,15 +189,24 @@ module OneDBFsck
|
||||
e.text = "users"
|
||||
end
|
||||
|
||||
users_fix[row[:oid]] = doc.to_s
|
||||
else
|
||||
group[gid] << row[:oid]
|
||||
users_fix[row[:oid]] = {:body => doc.to_s, :gid => user_gid}
|
||||
end
|
||||
|
||||
if gid != row[:gid]
|
||||
log_error(
|
||||
"User #{row[:oid]} is in group #{gid}, but the DB "<<
|
||||
"table has GID column #{row[:gid]}")
|
||||
|
||||
users_fix[row[:oid]] = {:body => doc.to_s, :gid => user_gid}
|
||||
end
|
||||
|
||||
group[user_gid] << row[:oid]
|
||||
end
|
||||
|
||||
users_fix.each do |id, body|
|
||||
@db[:user_pool].where(:oid => id).update(:body => body)
|
||||
users_fix.each do |id, user|
|
||||
@db[:user_pool].where(:oid => id).update(
|
||||
:body => user[:body],
|
||||
:gid => user[:gid])
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user