This file is indexed.

/usr/bin/gsmartcontrol-root is in gsmartcontrol 1.1.3-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env bash
############################################################################
# Copyright:
#      (C) 2008 - 2014  Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################

# Run gsmartcontrol with root, asking for root password first.
# export GSMARTCONTROL_SU to override a su command (e.g. "kdesu -c").

EXEC_BIN="/usr/sbin/gsmartcontrol";
prog_name="gsmartcontrol"


# Preserve quotes in arguments
final_args_quoted="";
for i in "$@";do
    final_args_quoted="$final_args_quoted \"${i//\"/\\\"}\"";
done;


DESKTOP="auto";

# Compatibility with old syntax:
# gsmartcontrol-root [<desktop> [program_options]]
if [ "$1" == "auto" ] || [ "$1" == "kde" ] || [ "$1" == "gnome" ] || [ "$1" == "other" ]; then
	DESKTOP="$1";
	shift;  # remove $1
else
	# New syntax:
	# gsmartcontrol-root [--desktop=<auto|kde|gnome|other>] [program_options]

	for arg in $*; do
		case $arg in
			--desktop=*)
				DESKTOP="${arg#*=}";
				final_args_quoted="${final_args_quoted/\"$arg\"/}";
				;;
			*)
				# unknown option
				;;
		esac
	done
fi

if [ "$DESKTOP" != "auto" ] && [ "$DESKTOP" != "kde" ] && \
		[ "$DESKTOP" != "gnome" ] && [ "$DESKTOP" != "other" ]; then
	echo "Usage: $0 [--desktop=<auto|kde|gnome|other>] [<${prog_name}_options>]";
	exit 1;
fi


# Auto-detect current desktop if auto was specified.
if [ "$DESKTOP" = "auto" ]; then
	# KDE_SESSION_UID is present on kde3 and kde4.
	# Note that it may be empty (but still set)
	if [ "${KDE_SESSION_UID+set}" = "set" ]; then
		DESKTOP="kde";
	# same with gnome
	elif [ "${GNOME_DESKTOP_SESSION_ID+set}" = "set" ]; then
		DESKTOP="gnome";
	else
		DESKTOP="other";
	fi
fi

# echo $DESKTOP;





# They're basically the same, only the order is different.
# pkexec is for PolKit.
# sux requires xterm to ask for the password.
# xdg-su is basically like this script, except worse :)
# su-to-root is a debian/ubuntu official method (although gksu is available).
gnome_sus="pkexec su-to-root gnomesu gksu kdesu beesu xdg-su sux";
kde_sus="pkexec su-to-root kdesu gnomesu gksu beesu xdg-su sux";
other_sus="$gnome_sus";


candidates="";
found_su=""

if [ "$DESKTOP" = "gnome" ]; then
	candidates="$gnome_sus";
elif [ "$DESKTOP" = "kde" ]; then
	candidates="$kde_sus";
elif [ "$DESKTOP" = "other" ]; then
	candidates="$other_sus";
fi

if [ "$GSMARTCONTROL_SU" = "" ]; then
	for subin in $candidates; do
		which $subin &>/dev/null
		if [ $? -eq 0 ]; then
			found_su="$subin";
			break;
		fi
	done

	if [ "$found_su" = "" ]; then
		xmessage "Error launching ${prog_name}: No suitable su mechanism found.
Try installing PolKit, kdesu, gnomesu, gksu, beesu or sux first.";
		exit 1;
	fi
fi


# gnomesu and gksu (but not kdesu, not sure about others) fail to adopt
# root's PATH. Since the user's PATH may not contain /usr/sbin (with smartctl)
# on some distributions (e.g. mandriva), add it manually. We also add
# /usr/local/sbin, since that's the default location of custom-compiled smartctl.
# Add these directories _before_ existing PATH, so that the user is not
# tricked into running it from some other path (we're running as root with
# the user's env after all).
# Add /usr/sbin as well (freebsd seems to require it).
# Note that beesu won't show a GUI login box if /usr/sbin is before /usr/bin,
# so add it first as well.
EXTRA_PATHS="/usr/bin:/usr/sbin:/usr/local/sbin:/usr/sbin";
export PATH="$EXTRA_PATHS:$PATH"


# echo $found_su;

# Examples:
# gnomesu -c 'gsmartcontrol --no-scan'
# kdesu -c 'gsmartcontrol --no-scan'
# beesu -P 'gsmartcontrol --no-scan'
# su-to-root -X -c 'gsmartcontrol --no-scan'
# xterm -e sux -c 'gsmartcontrol --no-scan'  # sux asks for password in a terminal


full_cmd="";

if [ "$GSMARTCONTROL_SU" != "" ]; then
	full_cmd="$GSMARTCONTROL_SU '$EXEC_BIN $final_args_quoted'";

elif [ "$found_su" = "pkexec" ]; then
	if [ "$GDK_SCALE" != "" ]; then
		final_args_quoted="$final_args_quoted --gdk-scale='$GDK_SCALE'"
	fi
	if [ "$GDK_DPI_SCALE" != "" ]; then
		final_args_quoted="$final_args_quoted --gdk-dpi-scale='$GDK_DPI_SCALE'"
	fi
	full_cmd="pkexec --disable-internal-agent $EXEC_BIN $final_args_quoted";

elif [ "$found_su" = "sux" ]; then
	full_cmd="xterm -e sux -c '$EXEC_BIN $final_args_quoted'";

elif [ "$found_su" = "gksu" ]; then
	full_cmd="$found_su '$EXEC_BIN $final_args_quoted'";

elif [ "$found_su" = "beesu" ]; then
	full_cmd="$found_su -P '$EXEC_BIN $final_args_quoted'";

elif [ "$found_su" = "su-to-root" ]; then
	full_cmd="$found_su -X -c '$EXEC_BIN $final_args_quoted'";

else  # gnomesu, kdesu, xdg-su
	full_cmd="$found_su -c '$EXEC_BIN $final_args_quoted'";
fi


# echo $full_cmd
eval $full_cmd