Ignore:
Timestamp:
2024-09-19T17:42:45+02:00 (3 weeks ago)
Author:
taylor.smock
Message:

Fix #20508: KWallet5 isn't working

This attempts to iterate through different KWallet versions

Location:
applications/editors/josm/plugins/native-password-manager
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/native-password-manager/build.xml

    r36211 r36339  
    55    <property name="commit.message" value="Commit message"/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="18991"/>
     7    <property name="plugin.main.version" value="19044"/>
    88    <property name="plugin.author" value="Paul Hartmann"/>
    99    <property name="plugin.class" value="org.openstreetmap.josm.plugins.npm.NPMPlugin"/>
  • applications/editors/josm/plugins/native-password-manager/pom.xml

    r36325 r36339  
    1717    <properties>
    1818        <plugin.src.dir>src</plugin.src.dir>
    19         <plugin.main.version>18991</plugin.main.version>
     19        <plugin.main.version>19044</plugin.main.version>
    2020        <plugin.author>Paul Hartmann</plugin.author>
    2121        <plugin.class>org.openstreetmap.josm.plugins.npm.NPMPlugin</plugin.class>
  • applications/editors/josm/plugins/native-password-manager/src/org/netbeans/modules/keyring/kde/KWalletProvider.java

    r35665 r36339  
    6262    private char[] handler = "0".toCharArray();
    6363    private boolean timeoutHappened = false;
    64     private char[] defaultLocalWallet = "kdewallet".toCharArray();
     64    private final char[] defaultLocalWallet = "kdewallet".toCharArray();
    6565
    6666    @Override
     
    100100                warning("save action failed");
    101101            }
    102             return;
    103102        }
    104103        //throw new KwalletException("save");
     
    113112                warning("delete action failed");
    114113            }
    115             return;
    116114        }
    117115        //throw new KwalletException("delete");
     
    122120            return false;
    123121        }
    124         handler = new String(handler).equals("")? "0".toCharArray() : handler;
     122        handler = new String(handler).isEmpty() ? "0".toCharArray() : handler;
    125123        CommandResult result = runCommand("isOpen",handler);         
    126124        if(new String(result.retVal).equals("true")){
     
    157155
    158156    private CommandResult runCommand(String command,char[]... commandArgs) {
     157        CommandResult result = null;
     158        for (int i : new int[] {6, 5, 0}) {
     159            result = runCommandKdeVersion(i, command, commandArgs);
     160            if (result.exitCode == 0 && !result.errVal.equals("Service 'org.kde.kwalletd" + (i != 0 ? i : "") + "' does not exist.")) {
     161                break;
     162            }
     163        }
     164        return result;
     165    }
     166
     167    private CommandResult runCommandKdeVersion(int kdeVersion, String command, char[]... commandArgs) {
    159168        String[] argv = new String[commandArgs.length+4];
    160169        argv[0] = "qdbus";
    161         argv[1] = "org.kde.kwalletd";
    162         argv[2] = "/modules/kwalletd";
     170        argv[1] = "org.kde.kwalletd" + (kdeVersion != 0 ? kdeVersion : "");
     171        argv[2] = "/modules/kwalletd" + (kdeVersion != 0 ? kdeVersion : "");
    163172        argv[3] = "org.kde.KWallet."+command;
    164173        for (int i = 0; i < commandArgs.length; i++) {
    165             //unfortunatelly I cannot pass char[] to the exec in any way - so this poses a security issue with passwords in String() !
     174            //unfortunately I cannot pass char[] to the exec in any way - so this poses a security issue with passwords in String() !
    166175            //TODO: find a way to avoid changing char[] into String
    167176            argv[i+4] = new String(commandArgs[i]);
     
    181190                String line;
    182191                while((line = input.readLine()) != null) {
    183                     if (!retVal.equals("")){
     192                    if (!retVal.isEmpty()){
    184193                        retVal = retVal.concat("\n");
    185194                    }
     
    191200                String line;
    192201                while((line = input.readLine()) != null) {
    193                     if (!errVal.equals("")){
     202                    if (!errVal.isEmpty()){
    194203                        errVal = errVal.concat("\n");
    195204                    }
     
    204213            }       
    205214        } catch (InterruptedException ex) {
     215            Thread.currentThread().interrupt();
    206216            logger.log(Level.FINE,
    207217                    "exception thrown while invoking the command \""+Arrays.toString(argv)+"\"",
     
    224234 
    225235    private static class CommandResult {
    226         private int exitCode;
    227         private char[] retVal;
     236        private final int exitCode;
     237        private final char[] retVal;
     238        private final String errVal;
    228239
    229240        public CommandResult(int exitCode, char[] retVal, String errVal) {
    230241            this.exitCode = exitCode;
    231242            this.retVal = retVal;
     243            this.errVal = errVal;
    232244        }                       
    233245    }
Note: See TracChangeset for help on using the changeset viewer.