Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

allow root to use sudo #9932

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions frame/sudo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
//! This is an example of a pallet that exposes a privileged function:
//!
//! ```
//!
//!
//! #[frame_support::pallet]
//! pub mod logger {
//! use frame_support::pallet_prelude::*;
Expand Down Expand Up @@ -196,9 +196,11 @@ pub mod pallet {
origin: OriginFor<T>,
new: <T::Lookup as StaticLookup>::Source,
) -> DispatchResultWithPostInfo {
// This is a public call, so we ensure that the origin is some signed account.
let sender = ensure_signed(origin)?;
ensure!(sender == Self::key(), Error::<T>::RequireSudo);
if ensure_root(origin.clone()).is_err() {
let sender = ensure_signed(origin)?;
ensure!(sender == Self::key(), Error::<T>::RequireSudo);
}

let new = T::Lookup::lookup(new)?;

Self::deposit_event(Event::KeyChanged(Self::key()));
Expand Down Expand Up @@ -233,9 +235,10 @@ pub mod pallet {
who: <T::Lookup as StaticLookup>::Source,
call: Box<<T as Config>::Call>,
) -> DispatchResultWithPostInfo {
// This is a public call, so we ensure that the origin is some signed account.
let sender = ensure_signed(origin)?;
ensure!(sender == Self::key(), Error::<T>::RequireSudo);
if ensure_root(origin.clone()).is_err() {
let sender = ensure_signed(origin)?;
ensure!(sender == Self::key(), Error::<T>::RequireSudo);
}

let who = T::Lookup::lookup(who)?;

Expand Down