Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No output of error messages in the user interface #78

Open
rhabacker opened this issue Feb 20, 2023 · 4 comments
Open

No output of error messages in the user interface #78

rhabacker opened this issue Feb 20, 2023 · 4 comments

Comments

@rhabacker
Copy link
Contributor

rhabacker commented Feb 20, 2023

When configuring a new directory server in the Yasdt2 auth server module, the input of a password is required. If this password does not meet the hidden requirements, Yast2 simply outputs that the user should lock to a log file to find out the real reasons for the failure.

The mentioned log file show:

2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87 DEBUG: PASSED: instance checking
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87 DEBUG: root_password must be at least 8 characters long
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87 Traceback (most recent call last):
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87   File "/usr/sbin/dscreate", line 99, in <module>
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87     result = args.func(inst, log, args)
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87   File "/usr/lib/python3.6/site-packages/lib389/cli_ctl/instance.py", line 71, in instance_create
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87     if sd.create_from_inf(args.file):
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87   File "/usr/lib/python3.6/site-packages/lib389/instance/setup.py", line 560, in create_from_inf
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87     self.create_from_args(general, slapd, backends, self.extra)
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87   File "/usr/lib/python3.6/site-packages/lib389/instance/setup.py", line 685, in create_from_args
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87     self._prepare_ds(general, slapd, backends)
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87   File "/usr/lib/python3.6/site-packages/lib389/instance/setup.py", line 622, in _prepare_ds
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87     raise ValueError("root_password must be at least 8 characters long")
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87 ValueError: root_password must be at least 8 characters long
2023-02-20 13:30:01 <1> host(11996) [Ruby] dir/ds389.rb(append_to_log):87 ERROR: Error: root_password must be at least 8 characters long

It would be nice if such messages would be presented in the yast2 user interface e.g a message box should appear showing root_password must be at least 8 characters long in this case.

@rhabacker rhabacker changed the title yast2-auth-server package No output of error messages in the user interface Feb 20, 2023
@Firstyear
Copy link
Collaborator

It's probably far too hard to get this feedback from errors back up to yast. We'd either need to rewrite the whole thing in python and I don't have the time for that. Currently the way yast-auth-server works is a pretty janky hack where yast is basicly running pre-batched commands, which is extraordinarily fragile to say the least.

I'd much rather see people stop using this module so we can delete it, and have people use dscreate directly which is a far better user experience, much more robust and offers more options than yast can.

@dmulder
Copy link
Member

dmulder commented Feb 21, 2023

You can write a yast python module which is called by the ruby code. Then you could catch and return the error.

@dmulder
Copy link
Member

dmulder commented Feb 21, 2023

Something like this:

from yast import Declare, ycpbuiltins, import_module
import_module('PackageSystem')
import_module('Package')
from yast import PackageSystem, Package
if not PackageSystem.Installed('lib389'):
    if not Package.InstallAll(['lib389']):
        raise ImportError("Failed to install lib389")
import_module('UI')
from lib389 import DirSrv
from lib389.cli_ctl import instance as cli_instance
from lib389.cli_base import setup_script_logger
from lib389.cli_base import format_error_to_dict

def ErrorMessage(msg):
    UI.OpenDialog(
        VBox(
            Label(msg),
            PushButton(Opt("default"), "&OK")
        )
    )
    UI.UserInput()
    UI.CloseDialog()

@Declare('boolean', 'map')
def InstanceCreate(args):
    log = setup_script_logger("dscreate", False)
    inst = DirSrv(verbose=False)
    result = False
    try:
        result = cli_instance.instance_create(inst, log, args)
    except Exception as e:
        msg = format_error_to_dict(e)
        ErrorMessage("Error: %s" % " - ".join(str(val) for val in msg.values()))
        result = False
    return result

I haven't tested this at all, but quickly hacked something up. You put this in src/modules/dscreate.py, then you can call this from the ruby code by importing the yast module as usual.

You would also have to add yast2-python3-bindings as a dependency in the rpm spec.

@Firstyear
Copy link
Collaborator

Thanks, I didn't know you could do this. I'll have a better look early next week :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants