|
Lines 168-177
Link Here
|
| 168 |
next if $line->{kind} ne "value"; |
168 |
next if $line->{kind} ne "value"; |
| 169 |
next if $line->{type} and not $section->{type}; # commented line |
169 |
next if $line->{type} and not $section->{type}; # commented line |
| 170 |
|
170 |
|
| 171 |
$self->ShareSetStr($share, $line->{name}, $line->{value}); |
171 |
if (defined $Config{$share}{$line->{name}}) { |
|
|
172 |
y2internal ("key '".$line->{name}."' already present"); |
| 173 |
y2internal ("original value: ", $Config{$share}{$line->{name}}); |
| 174 |
y2internal ("current value: ", $line->{value}); |
| 175 |
$self->ShareAddStr($share, $line->{name}, $line->{value}); |
| 176 |
} |
| 177 |
else { |
| 178 |
$self->ShareSetStr($share, $line->{name}, $line->{value}); |
| 179 |
} |
| 172 |
} |
180 |
} |
| 173 |
} |
181 |
} |
| 174 |
$self->UnsetModified(); |
182 |
$self->UnsetModified(); |
|
|
183 |
|
| 184 |
y2warning ("global section read:", Dumper ($Config{"global"})); |
| 175 |
|
185 |
|
| 176 |
y2debug("Readed config: ".Dumper(\%Config)); |
186 |
y2debug("Readed config: ".Dumper(\%Config)); |
| 177 |
return 1; |
187 |
return 1; |
|
Lines 194-207
Link Here
|
| 194 |
if (!defined $val) { |
204 |
if (!defined $val) { |
| 195 |
SCR->Write(".etc.smb.value.global.$key", undef); |
205 |
SCR->Write(".etc.smb.value.global.$key", undef); |
| 196 |
} else { |
206 |
} else { |
| 197 |
SCR->Write(".etc.smb.value.global.$key", String($val)); |
207 |
if (ref ($val) ne "ARRAY") { |
|
|
208 |
$val = [ String($val) ]; |
| 209 |
} |
| 210 |
SCR->Write(".etc.smb.value.global.$key", $val); |
| 211 |
# SCR->Write(".etc.smb.value.global.$key", String($val)); |
| 198 |
# ensure option is not commented |
212 |
# ensure option is not commented |
| 199 |
SCR->Write(".etc.smb.value_type.global.$key", Integer(0)); |
213 |
SCR->Write(".etc.smb.value_type.global.$key", [Integer(0)]); |
| 200 |
} |
214 |
} |
| 201 |
} |
215 |
} |
| 202 |
|
216 |
|
| 203 |
# ensure global section is not commented |
217 |
# ensure global section is not commented |
| 204 |
SCR->Write(".etc.smb.section_type.global", Integer(0)); |
218 |
SCR->Write(".etc.smb.section_type.global", [Integer(0)]); |
| 205 |
|
219 |
|
| 206 |
# remove modified flag |
220 |
# remove modified flag |
| 207 |
$Config{global}{_modified} = undef; |
221 |
$Config{global}{_modified} = undef; |
|
Lines 230-242
Link Here
|
| 230 |
if (!defined $val) { |
244 |
if (!defined $val) { |
| 231 |
SCR->Write(".etc.smb.value.$share.$key", undef); |
245 |
SCR->Write(".etc.smb.value.$share.$key", undef); |
| 232 |
} else { |
246 |
} else { |
| 233 |
my $ret1 = SCR->Write(".etc.smb.value.$share.$key", String($val)); |
247 |
if (ref ($val) ne "ARRAY") { |
| 234 |
my $ret = SCR->Write(".etc.smb.value_type.$share.$key", Integer($commentout)); |
248 |
$val = [ String($val) ]; |
|
|
249 |
} |
| 250 |
# my $ret1 = SCR->Write(".etc.smb.value.$share.$key", String($val)); |
| 251 |
my $ret1 = SCR->Write(".etc.smb.value.$share.$key", $val); |
| 252 |
my $ret = SCR->Write(".etc.smb.value_type.$share.$key", [ Integer($commentout)]); |
| 235 |
} |
253 |
} |
| 236 |
}; |
254 |
}; |
| 237 |
|
255 |
|
| 238 |
# write the type and comment of the section |
256 |
# write the type and comment of the section |
| 239 |
SCR->Write(".etc.smb.section_type.$share", Integer($commentout)); |
257 |
SCR->Write(".etc.smb.section_type.$share", [Integer($commentout)]); |
| 240 |
my $comment = $Config{$share}{_comment} || ""; |
258 |
my $comment = $Config{$share}{_comment} || ""; |
| 241 |
$comment =~ s/\n*$//; |
259 |
$comment =~ s/\n*$//; |
| 242 |
$comment =~ s/^\n*//; |
260 |
$comment =~ s/^\n*//; |
|
Lines 245-251
Link Here
|
| 245 |
} |
263 |
} |
| 246 |
$comment =~ s/^(?![#;])/; /mg if $comment; |
264 |
$comment =~ s/^(?![#;])/; /mg if $comment; |
| 247 |
$comment .= "\n" if $comment; |
265 |
$comment .= "\n" if $comment; |
| 248 |
SCR->Write(".etc.smb.section_comment.$share", String("\n$comment")); |
266 |
SCR->Write(".etc.smb.section_comment.$share", [String("\n$comment")]); |
| 249 |
|
267 |
|
| 250 |
# remove modified flag |
268 |
# remove modified flag |
| 251 |
$Config{$share}{_modified} = undef; |
269 |
$Config{$share}{_modified} = undef; |
|
Lines 384-389
Link Here
|
| 384 |
return defined $Config{$share}{$key} ? $Config{$share}{$key} : $default; |
402 |
return defined $Config{$share}{$key} ? $Config{$share}{$key} : $default; |
| 385 |
} |
403 |
} |
| 386 |
|
404 |
|
|
|
405 |
# add share key value |
| 406 |
# FIXME (not possible for InvertedSynonyms, no deleting, no checking for changes |
| 407 |
BEGIN{ $TYPEINFO{ShareAddStr} = ["function", "boolean", "string", "string", "string"]; } |
| 408 |
sub ShareAddStr { |
| 409 |
my ($self, $share, $key, $val) = @_; |
| 410 |
if (not defined $share) { |
| 411 |
y2error("undefned share"); |
| 412 |
return undef; |
| 413 |
} |
| 414 |
if (not defined $key) { |
| 415 |
y2error("undefned key"); |
| 416 |
return undef; |
| 417 |
} |
| 418 |
$key = lc($key); |
| 419 |
$key = $Synonyms{$key} if exists $Synonyms{$key}; |
| 420 |
|
| 421 |
my $old = $Config{$share}{$key}; |
| 422 |
if (ref ($old) ne "ARRAY") { |
| 423 |
$Config{$share}{$key} = []; |
| 424 |
if (defined $old) { |
| 425 |
push @{$Config{$share}{$key}}, $old; |
| 426 |
} |
| 427 |
} |
| 428 |
push @{$Config{$share}{$key}}, $val; |
| 429 |
|
| 430 |
$self->ShareSetModified($share); |
| 431 |
return 1; |
| 432 |
} |
| 433 |
|
| 387 |
# set share key value, return old value |
434 |
# set share key value, return old value |
| 388 |
BEGIN{ $TYPEINFO{ShareSetStr} = ["function", "boolean", "string", "string", "string"]; } |
435 |
BEGIN{ $TYPEINFO{ShareSetStr} = ["function", "boolean", "string", "string", "string"]; } |
| 389 |
sub ShareSetStr { |
436 |
sub ShareSetStr { |