在config.xml中禁用Jenkins安全性后无法恢复

时间:2013-08-20 10:01:33

标签: jenkins hudson

昨天,我在尝试配置ldap身份验证时将自己锁定在jenkins之外,因此我按照wiki中的说明操作,并通过ssh禁用config.xml文件中的安全性。现在我想恢复正常的jenkins安全性,但是在“配置Jenkins”下不再提供这种可能性。所以我正在寻找通过config.xml恢复正常安全性的可能性。

以下是当前config.xml文件的相关部分:

<hudson>
  <disabledAdministrativeMonitors/>
  <version>1.477</version>
  <numExecutors>3</numExecutors>
  <mode>NORMAL</mode>
  <useSecurity>true</useSecurity>
  <authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
  <securityRealm class="hudson.security.SecurityRealm$None"/>
  ...
</hudson>

有人有想法或者可能是config.xml的有效部分吗?

6 个答案:

答案 0 :(得分:3)

不要忘记按照#6点删除authorizationStrategy和securityRealm:

https://wiki.jenkins-ci.org/display/JENKINS/Disable+security

答案 1 :(得分:2)

<useSecurity>true</useSecurity>

只需将其更改为False即可。然后,您可以从一开始就访问Jenkins配置。

答案 2 :(得分:0)

您错过了设置以下内容:

<useSecurity>false</useSecurity>

答案 3 :(得分:0)

    <hudson>
      <disabledAdministrativeMonitors/>
      <version>2.130</version>
      <numExecutors>2</numExecutors>
      <mode>NORMAL</mode>
      <useSecurity>true</useSecurity>
      <authorizationStrategy class="hudson.security.FullControlOnceLoggedInAuthorizationStrategy">
        <denyAnonymousReadAccess>true</denyAnonymousReadAccess>
      </authorizationStrategy>
      <securityRealm class="hudson.security.HudsonPrivateSecurityRealm">
        <disableSignup>true</disableSignup>
        <enableCaptcha>false</enableCaptcha>
      </securityRealm>
      ...
    </hudson>

我认为您正在寻找它,因为我能够将其还原为我的默认config.xml。记住,始终在修改配置之前对其进行备份。 只需更新这两个标签authorizationStrategy和securityRealm,就可以了。并作进一步参考,请查看 jenkins_xml_reference

答案 4 :(得分:0)

将这三个设置添加/替换为配置( /** * Call a given number * * @param context * @param number */ public static void call(@NotNull Context context, @NotNull String number) { try { // Create call intent Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Uri.encode(number))); // Handle sim card selection // int simCard = getSimSelection(context); // Timber.d("simcard "+simCard); // if (simCard != -1) callIntent.putExtra("com.android.phone.extra.slot", simCard); callIntent.setFlags(FLAG_ACTIVITY_NEW_TASK); // Start the call context.startActivity(callIntent); } catch (SecurityException e) { Toast.makeText(context, "Couldn't make a call due to security reasons", Toast.LENGTH_LONG).show(); } catch (NullPointerException e) { Toast.makeText(context, "Couldnt make a call, no phone number", Toast.LENGTH_LONG).show(); } } /** * Places a new outgoing call to the provided address using the system telecom service with * the specified intent. * * @param activity {@link Activity} used to start another activity for the given intent * @param telecomManager the {@link TelecomManager} used to place a call, if possible * @param intent the intent for the call */ public static boolean placeCall(@Nullable FragmentActivity activity, @Nullable TelecomManager telecomManager, @Nullable Intent intent) { if (activity == null || telecomManager == null || intent == null) { return false; } if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { return false; } telecomManager.placeCall(intent.getData(), intent.getExtras()); return true; // activity.startActivityForResult(intent, 1291); // return true; } 可以达到目的(例如,当我将~/jenkins_home/config.xml更改为<useSecurity>true</useSecurity>并随后恢复时,永久恢复登录页面到<useSecurity>false</useSecurity>的状态未按预期恢复原状):

true

旁注:在我的情况下,当我从BasicAuth切换到OAuth时,忘记了将新用户添加到Jenkins管理的内部用户数据库(与Github用户名匹配)的情况下发生锁定

答案 5 :(得分:-1)

即使我遇到了同样的问题,但后来我可以解决这个问题。

我们需要删除以下行末尾的nav{ width: 100%; } ul{ display: table; width: 100%; } ul li{ display: table-cell; width: 1%; text-align: center; }

/

应为<securityRealm class="hudson.security.SecurityRealm$None"/>

这对我有用。