0

I'm wondering how the Common Unix Printing System "CUPS" handels the user actions and affects the configuration files, from my humble background, a webpage only can access/edit files when there is some web server and a serverside script, so how it works without installing web server? does it work through some shell script? if yes, how that occurs?

Ahmed Waheed
  • 1,281
  • 5
  • 21
  • 39
  • Here are links to http.c and cgi-bin https://stackoverflow.com/questions/41081105/why-cups-ships-a-web-server-instead-of-using-httpd – Sergey Ponomarev Jan 20 '21 at 11:00

1 Answers1

0

It is not the web frontend that alters the configuration files. At least not if you compare it to the 'typical' setup: http server, scripting engine, script.

CUPS itself contains a daemon, this also acts as a minimal web server. That deamon has control over the configuration files. And it is free to accept commands from some web client it serves. So no magic here.

Turned that around you could also setup a system running a 'normal' http server with such rights that is is able to alter all system configuration files. That's all a question of how that server/daemon is setup and started. It breaks down to simple rights management. You certainly do not want to do that, though ;-)

arkascha
  • 41,620
  • 7
  • 58
  • 90
  • and where/what is the "code" that alter the configuration files upon the interaction with the web interface?? is it shell scripts?? – Ahmed Waheed Jan 29 '13 at 10:08
  • The daemon is the code, it is mostly implemented in c++, as most daemons are. A daemon is a 'normal' application, only that it is typically started at system startup und is granted specific permissions. So unike an application that is started by a user. Every application consists of 'code' in some form. Some of that code in the CUPS daemon acts as a minimal http server (that is easy to implement). So there are no 'scripts' in the sense as one can see in todays typical web applciations. CUPS does contain many scripts, but those deal with processing of documents. – arkascha Jan 29 '13 at 10:11
  • well, can you provide me with any resources about how to make a web interface and handle it with another application(daemon).. like in this case? – Ahmed Waheed Jan 29 '13 at 10:49
  • For all programming languages some libraries exist that implement a basic http server. So you have to implement an application (in whatever language you chose, c/c++ certainly preferred for daemons) and use such library to add an http service. During startup that service has to bind to a port (typially _not_ port 80) or another socket listener type. An intelligent start would be to use c++ with the great Qt toolkit. Qt offers 'QHttpServer' (http://qt-project.org/forums/viewthread/3658) which you can use as a starting point. – arkascha Jan 29 '13 at 11:00