aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* Add openSUSE package infoGravatar Michael Vetter2019-04-30
|
* Version bump to 0.4Gravatar Mykyta Holubakha2018-09-04
|
* Fix read_device returnGravatar Hummer120072018-07-22
| | | closes #24
* Considered bitfields harmfulGravatar Mykyta Holubakha2018-07-13
|
* Refactor to use stdbool.h for consistent booleansGravatar Mykyta Holubakha2018-07-13
|
* Create temporary directory under XDG_RUNTIME_DIRGravatar Mykyta Holubakha2018-07-13
| | | | | | fallback to /tmp closes #22
* Install udev rules by defaultGravatar Mykyta Holubakha2018-07-13
|
* Added flag to dissallow setting brightness to zero when using delta values (#21)Gravatar Thomas Ingram2018-06-25
| | | | | | | | * Added flag never-zero that stops brightness being set to 0. * Updated README to show never-zero flag. * Replaced never-zero with min-value flag
* Add Void Linux packageGravatar Daniel Santana2018-04-24
|
* Revert manpage changesGravatar Mykyta Holubakha2018-01-24
|
* Improved manpageGravatar Mykyta Holubakha2018-01-24
| | | | thanks @SirCmpwn
* Credit myself for the manpageGravatar Nicolas Braud-Santoni2018-01-24
|
* Add brightnessctl(1) manpageGravatar Nicolas Braud-Santoni2018-01-24
|
* Release 0.3.1Gravatar Mykyta Holubakha2018-01-19
|
* README: mention Debian/Ubuntu packagesGravatar Mykyta Holubakha2018-01-19
|
* Allow to specify device name as a wildcardGravatar Mykyta Holubakha2018-01-19
|
* Added swap files to gitignoreGravatar Mykyta Holubakha2018-01-19
|
* Specify -lm after the main executable symbolGravatar Hummer120072017-10-23
| | | | | Specifying it before may cause issues with some compilers Minor ws cleanup in makefile
* Use BINDIR in Makefile install ruleGravatar Miciah Masters2017-09-23
|
* Fix file mode for installing non-suid binaryGravatar Miciah Masters2017-09-23
| | | | | Use the file mode 0755 (executable but not suid) when installing the binary with INSTALL_UDEV_RULES=1.
* Version bump to 0.3Gravatar Mykyta Holubakha2017-09-22
| | | | | | | | | | fixes #10 added an option to install udev rules (fixes #11) updated makefile to adhere to DESTDIR/PREFIX conventions updated README
* Fix rounding errors when using percentagesGravatar Markus Schneider2017-08-26
|
* Add --version flagGravatar Christoph Gysin2017-07-28
|
* Add "info" operation and make it defaultGravatar hcpl2017-07-28
| | | | There should be an option to get a sole "current brightness" value.
* Update READMEGravatar hcpl2017-07-28
|
* Add gitignoreGravatar Christoph Gysin2017-07-28
|
* Add comment to silence -Wimplicit-fallthroughGravatar Christoph Gysin2017-07-28
|
* Remove trailing whitespaceGravatar Christoph Gysin2017-07-28
|
* Make it more portableGravatar Mykyta Holubakha2017-06-11
|
* Update README.mdGravatar benjiprod2017-05-05
| | | Dead link on AUR.
* Add AUR to READMEGravatar Hummer120072017-02-18
|
* Fix logical errorsGravatar Mykyta Holubakha2017-01-18
| | | | | | | | | | Restore device data only after successful read Do not set curr_brightness to max after an unsuccessful restore Fix ensure_dir Do not ignore ignore value of fread (fixes #6)
* Version bumpGravatar Mykyta Holubakha2017-01-17
|
* Readme hotfixGravatar Hummer120072017-01-17
|
* Readme hotfixGravatar Hummer120072017-01-17
|
* Updated readmeGravatar Mykyta Holubakha2017-01-17
|
* No longer require root privilegesGravatar Mykyta Holubakha2017-01-17
|
* Ensure state files are world-writableGravatar Mykyta Holubakha2017-01-15
|
* Refactor directory accessGravatar Mykyta Holubakha2017-01-15
| | | | Add static specifier to functions
* Updated makefileGravatar Mykyta Holubakha2017-01-15
|
* Fix a null-pointer dereference in read_deviceGravatar Mykyta Holubakha2017-01-15
|
* Merge pull request #5 from Miciah/various-fixesGravatar Hummer120072017-01-15
|\ | | | | Various fixes
| * Print error if run dir is not a directoryGravatar Miciah Masters2017-01-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Print an error message if the run directory or the device-class subdirectory exists but is not a directory. Before: % rm -rf /tmp/brightnessctl % touch /tmp/brightnessctl % brightnessctl -s Device 'intel_backlight' of class 'backlight': Current brightness: 1000 (20%) Max brightness: 4794 % file /tmp/brightnessctl /tmp/brightnessctl: empty % After: % brightnessctl -s Error saving device data: Not a directory Could not save data for device 'intel_backlight'. Device 'intel_backlight' of class 'backlight': Current brightness: 1000 (20%) Max brightness: 4794 %
| * Clean up error handlingGravatar Miciah Masters2017-01-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make several changes to error handling: • Check for negative values from sprintf, and treat them as errors. • Check for errors from fscanf both by comparing its return value against EOF and by checking ferror. • Avoiding calling perror with errno set to -1. Either set a meaningful value, such as EINVAL, or use fprintf if errno cannot be expected to have a meaningful value. • Instead of re-using errno for internal error handling, use a new variable to indicate errors where it makes sense to do so. • In read_device, print more specific error messages if we fail to read a device's current or max brightness, and print an error message immediately if a read fails, instead of only maybe at the end of read_device.
| * Do not write NUL to state fileGravatar Miciah Masters2017-01-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do not write a trailing NUL byte to the state file. Before: % brightnessctl -ms intel_backlight,backlight,1000,20%,4794 % od -t x1z /tmp/brightnessctl/backlight/intel_backlight 0000000 31 30 30 30 00 >1000.< 0000005 % After: % brightnessctl -ms intel_backlight,backlight,1000,20%,4794 % od -t x1z /tmp/brightnessctl/backlight/intel_backlight 0000000 31 30 30 30 >1000< 0000004 % Note that restore still works: % brightnessctl -mr intel_backlight,backlight,1000,20%,4794 %
| * Fix logic for directory creation when saving stateGravatar Miciah Masters2017-01-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When creating the /tmp/brightnessctl directory or its subdirectories, clear errno before calling mkdir, and call stat a second time after mkdir. Previously, errno was not cleared, so even if the error was handled (by creating the missing directory with mkdir), subsequent error handling code read the old errno value from the failed stat call and printed an error message. Additionally, because we did not call stat again after calling mkdir, the stat buffer had outdated information, and so S_ISDIR returned a false negative. As a result of these defects, invoking brightnessctl -s when /tmp/brightnessctl did not exist would create /tmp/brightnessctl and fail. Invoking brightnessctl -s a second time would create /tmp/brightnessctl/backlight and fail. Invoking the command a third time would succeed and write the state file under /tmp/brightnessctl/backlight/. After this commit, brightnessctl -s succeeds the first time.
| * -r/--restore requires root, same as setGravatar Miciah Masters2017-01-15
| | | | | | | | | | | | The -r/--restore flag requires root, the same as the set verb does, so print an error message if either the flag or the verb is used without running as root.
| * Set dev_name to default device nameGravatar Miciah Masters2017-01-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If no device is specified with the --device flag, set dev_name to the id of the first device. Before, if the --device flag is not used to specify the default device, the dev pointer was set to first device found (see commit c9140d1e5070dae2746d3b70c0390075bd5380f6), but the dev_name pointer was left set to NULL. As a result, some error messages did not print the name of the default device: % brightnessctl -s Error saving device data: No such file or directory Could not save data for device '(null)'. Device 'intel_backlight' of class 'backlight': Current brightness: 1000 (20%) Max brightness: 4794 % brightnessctl -s -m Error saving device data: No such file or directory Could not save data for device '(null)'. intel_backlight,backlight,1000,20%,4794 % After this commit, all error messages have the correct name: % brightnessctl -s Error saving device data: No such file or directory Could not save data for device 'intel_backlight'. Device 'intel_backlight' of class 'backlight': Current brightness: 1000 (20%) Max brightness: 4794 % brightnessctl -s -m Error saving device data: No such file or directory Could not save data for device 'intel_backlight'. intel_backlight,backlight,1000,20%,4794 %
| * Fix buffer overflow in cat_withGravatar Miciah Masters2017-01-09
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Account for separators when computing the buffer size in cat_width in order to avoid overflowing the buffer. Previously, cat_width only accounted for the lengths of the strings being catenated, but not the separators, which could result in buffer overflows. For example, trace the execution of the following invocation of cat_with: char s[5] = "xxxx"; cat_with(' ', s, s, s, s, s, s, s, s); cat_with initialises size and length and allocates an initial buffer: size = 32; /* size = 32 */ length = 0; /* length = 0 */ buf = calloc(1, size + 1); /* allocated 33 bytes for buf */ The first iteration of the main loop in cat_with catenates the first string and a separator but fails to account for the separator in length: length += strlen(curr); /* length = 4 */ while (length + 2 > size) /* 4 + 2 > 32 is false */ strcat(buf, curr); /* written 5 bytes to buf */ strcat(buf, split); /* written 6 bytes to buf */ Now we have written the string "xxxx " (6 bytes including NUL) to buf, but length only counts the 4 bytes "xxxx" (excluding NUL). In successive iterations, the discrepancy between the value in length and the actual length of the string in the buffer grows: length += strlen(curr); /* length = 8 */ while (length + 2 > size) /* 8 + 2 > 32 is false */ strcat(buf, curr); /* written 10 bytes to buf */ strcat(buf, split); /* written 11 bytes to buf */ Now we have written "xxxx xxxx " (11 bytes incl. NUL). length += strlen(curr); /* length = 12 */ while (length + 2 > size) /* 12 + 2 > 32 is false */ strcat(buf, curr); /* written 15 bytes to buf */ strcat(buf, split); /* written 16 bytes to buf */ Now we have written "xxxx xxxx xxxx " (16 bytes incl. NUL). length += strlen(curr); /* length = 16 */ while (length + 2 > size) /* 16 + 2 > 32 is false */ strcat(buf, curr); /* written 20 bytes to buf */ strcat(buf, split); /* written 21 bytes to buf */ Now we have written "xxxx xxxx xxxx xxxx " (21 bytes incl. NUL). length += strlen(curr); /* length = 20 */ while (length + 2 > size) /* 20 + 2 > 32 is false */ strcat(buf, curr); /* written 25 bytes to buf */ strcat(buf, split); /* written 26 bytes to buf */ Now we have written "xxxx xxxx xxxx xxxx xxxx " (26 bytes incl. NUL). length += strlen(curr); /* length = 24 */ while (length + 2 > size) /* 24 + 2 > 32 is false */ strcat(buf, curr); /* written 30 bytes to buf */ strcat(buf, split); /* written 31 bytes to buf */ Now we have written "xxxx xxxx xxxx xxxx xxxx xxxx " (31 bytes incl. NUL). Eventually, the string can grow beyond the buffer before length grows large enough to cause a re-allocation: length += strlen(curr); /* length = 28 */ while (length + 2 > size) /* 28 + 2 > 32 is false */ strcat(buf, curr); /* written 35 bytes to buf */ strcat(buf, split); /* written 36 bytes to buf */ Note that we have not increased size or re-allocated the buffer, and so we have written "xxxx xxxx xxxx xxxx xxxx xxxx xxxx" (35 bytes incl. NUL) to a buffer for which we have allocated only 33 bytes.
* Document prefix-sign supportGravatar Mykyta Holubakha2017-01-07
|