Scripts diversos de C

This commit is contained in:
Tuxliban Torvalds 2022-11-28 00:49:38 -06:00
parent b2c4a8b35e
commit de55532d39
5 changed files with 36 additions and 2 deletions

BIN
varios/C/gcc_test Normal file

Binary file not shown.

33
varios/C/getvol.c Normal file
View File

@ -0,0 +1,33 @@
#include <alsa/asoundlib.h>
int main() {
snd_mixer_t *mixer;
if (snd_mixer_open(&mixer, 1) ||
snd_mixer_attach(mixer, "default") ||
snd_mixer_selem_register(mixer, NULL, NULL) ||
snd_mixer_load(mixer)) exit(42);
snd_mixer_selem_id_t *id;
snd_mixer_selem_id_alloca(&id);
snd_mixer_selem_id_set_index(id, 0);
snd_mixer_selem_id_set_name(id, "Master");
snd_mixer_elem_t *elem = snd_mixer_find_selem(mixer, id);
if (!elem) {
exit(5);
}
long min, max, vol;
snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
snd_mixer_selem_get_playback_volume(elem,
SND_MIXER_SCHN_FRONT_LEFT, &vol);
printf("%li%%", ((vol - min)*100 + (max - min)/2) / (max - min));
snd_mixer_close(mixer);
}

BIN
varios/glibc → varios/C/glibc Executable file → Normal file

Binary file not shown.

View File

@ -11,12 +11,13 @@
int main(int argc, const char const *argv[]) {
const char const *shell[] = { "/bin/sh", NULL };
// move glibc stuff in place
/* move glibc stuff in place */
e("unshare",unshare(CLONE_NEWNS));
e("mount",mount(SRC "/usr", "/usr", NULL, MS_BIND, NULL));
e("mount",mount(SRC "/opt", "/opt", NULL, MS_BIND, NULL));
e("mount",mount(SRC "/var/db/xbps", "/var/db/xbps", NULL, MS_BIND, NULL));
// drop the rights suid gave us
/* drop the rights suid gave us */
e("setuid",setreuid(getuid(),getuid()));
e("setgid",setregid(getgid(),getgid()));

BIN
varios/C/tcc_test Normal file

Binary file not shown.